### Session Expired sample

This page demonstrates how to detect and handle the case when the server is reporting that a session has expired.

It requires ColdFusion scripting enabled on the server.

The list of cities on the right side of the states is loaded by the 'dsCities' XMLDataSet using a server page that receives the state name as a parameter.
However, this page throws a session expired message after five requests (five clicks on the states), so the "expired" state for that spry:region is going to be displayed.

By default, XMLDataSet looks for "session expired" message in the text response that comes from the server or in the XML-formatted response. If such a message is found, the "expired" state is set for all the spry:regions that depend on the current DataSet.

1. {name}

The first 30 cities in the state of "{dsStates::name}":

1. {name}

Loading cities..
Error loading cities..
This sample requires CF support on the server.
Your session has expired!
You need to re-login in order to access the list of cities.
Username / password: admin / pass12
Username:
Password:

What is the response required from the server in order for XMLDataSet to detect "session expired" state?

- Send this string as the response:

      session expired

- Send this xml as the response:

      <?xml version="1.0" encoding="utf-8"?>
      <reply>session expired</reply>

- Send any kind of response, but make sure to pass a checker function to the XMLDataSet that will lookup your custom response:

      // the checker receives a request object
      function MySessionExpiredChecker(req)
      {
      	  if (req.xhRequest.responseText == 'my custom session expired string')
      		    return true;
      	  return false;
      }
      // pass this function to the dataset
      ds1.setSessionExpiredChecker(MySessionExpiredChecker);