I'm working with using session to authorize users. It works fine as long as they move between pages, and we've got the timeout set to two hours, so it usually won't be an issue. However, with the users we work with, I can imagine them getting preoccupied after doing work on a single page, then letting it sit for two hours. If the session times out, they lose the work, and I've already had testers unhappy with me because their session timed out (only 24 minutes then, though).
Is there a way to run a script when the session times out, so that I can at least ask the user to login again? I know I can do it via javascript -- if I modify every single one of the more than 100 .php scripts used by the website. But I have a single auth script, and if I could run it from there, it would be nice.
Thanks,
Sean.
Prompting the user using PHP or any other server-side scripting language is not possible without a refresh. You're basically asking your server to serve something that the browser didn't request, which is why its not possible. But as you already know you can use JavaScript to get the job done.
The following is not set in stone or true in all cases it just might apply to your situation. To run a script when a session times out you would have to :