View Full Version : handling Session timeout throughout app

25 Nov 2007, 2:10 PM

I'm building quite a few combobox elements for various forms using Ajax requests to PHP scripts that get the data for the combox elements. I'm using ArrayReaders, returning simple Json arrays to fill my comboboxes.

However, if the user's session has timed out, the combobox just dies. I'm trying to determine the best way to create an overall check utility so that I don't repeat myself over and over. I'd like to return something generic from my php code indicating a session timed out, so I can use the same code in Ajax calls to fill combo boxes, Ajax calls to submit forms, Ajax calls to get Grid data, etc.

Should I build my own sub-class of the combobox element and embed everything inside, including the data stores, proxies, and the session checking. Is there any easier way to do it? I tried sending a 404 header when the user isn't logged in and trying to use the loadexception handlers of the httpproxy class, but it seems very clunky to me. It seems like I should be able to return something

Any ideas? To summarize, I need to build a generic tool to verify that a user is logged in any time I make an Ajax request, whether it is for a combo box, data grid, or anything else.


25 Nov 2007, 3:13 PM
After pondering this a bit, I came up with this crazy solution:

What if your AJax requests are made resulting in either JSON or otherwise executable javascipt text (where an eventual eval is involved) and you server returned this when it determined the session was no longer valid?

Server reponseText:



Ext.MessageBox.show({title:'Session Timout'
,msg:'You session has expired.<br />Would you like to login again?'

} else {


return {success:false}; //satisfy the proxy/reader needs, if necessary