session handling issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
marcelobm
Forum Newbie
Posts: 4
Joined: Sun Mar 01, 2009 5:17 am

session handling issue

Post by marcelobm »

Hi Everyone, I was wondering if there is any way to excecute a script or function when a session has expired, even if the browser was closed.

Thank you in advance I hope someone can help me on this
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: session handling issue

Post by php_east »

session expiration can be checked when the session object is accessed.

if the browser is already closed, you need some script running mechanism to check for expired sessions in the session tables or files. it is some kind of watchdog routine. to do that you would need a CRON job with a maintanance script of some sort that will check for the expired sessions.

other application usually cheat and use user acesses as triggers to activate this watchdog routine, which of course has the disadvantage that if no one visits your site for a while, maintenance is simply not carried out. hence a CRON job is the correct way to do it.

depening on your session handling method, you can then check for the expired ones and do something on a regular basis, and this is regardless of wether the browser is alive or not.
it has infact nothing to do with the browser being closed or not.
Post Reply