Hi there,
I am aware that there are already a couple of posts regarding PHP session, however I could not find a satisfactory answer.
I have a session variable called “project_id” which I set once the user has opened a project. Now, in my forms I have an SQL WHERE clause in which I am using this variable. E.g. “idProject = [project_id]”. So far, so good, this is working fine. However, when the PHP session elapses, i.e. gets purged by the web server, then, when opening the form, I get an ugly error message telling me that some global variables are not set (“The following global variables are missing: …”). This error message is understandable as the session has elapsed. However, I cannot figure out a way to redirect the user to some login page in this situation or do something else which is nicer for the user. I tried adding some code in the “onApplicationInit” and “onScriptInit” event to detect missing variables, however the error is actually generated before any of the events available are processed.
I know that I could write some javascript which “pings” the server and does a redirect in case the session has elapsed. But I think that it is quite a lot of effort for such a common problem. I also read that one could write its own javascript based session timeout management, but I don’t think it is working in my case as the underlying SQL statement already fails, so I don’t get to the onApplicationInit events at all. One hack I could think of is to dramatically increase the PHP session timeout, say one full day, to basically disable the purging mechanism and then to implement the session timeout with javascript. However, I don’t want to do that as this is not the only application on this web server.
Is there a clean solution to overcome by problem ?
Thanks
Marcel