Avoid session expiration in Webapplications (e.g. PHP)

Some of you may have run into the problem that the default session timeout (about 15 minutes) isn't always useful if your users have to fill a large form with lots of text.

Often you get after those: 'Session timed out' and after login the user has to type all again. To fix that, you can wait for the login and refill the form with the saved data. That is not very handy and quite difficult to implement.

A very handy and fast fix for this session timeout is, that you query the server every minute once to keep the session alive without requiring the user to reload the page. I found out that that soloution is used even in SMF, so it seems to be quite common.

So just add the following lines to an extra page or the start of your index-file.

session_start(); if (isset($_GET['sessionfix']))Â? exit;

And now add the magic javascript, which updates that in the template or html file.

That's it!

In articles, open source, php by @ 27 Feb 2008

comments powered by Disqus

Recent Files


Recent Dev-Articles

Read recently