faqts : Computers : Programming : Languages : PHP : Common Problems : Sessions and State

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

49 of 61 people (80%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I log users out of a page after a certain time period?

Jul 10th, 1999 08:26
Nathan Wallace, Chris Adams


Stuff a META tag in the generated html:

    <META HTTP-EQUIV="REFRESH" CONTENT="300;logmeout.php3">

This would cause the browser to load the logout page ("Your session has
been timed out. Click here to login again.") after 300 seconds had
passed from the page being loaded.

If you wanted to be nice, you could have a 270 second time in JavaScript
(basically, you create a function and then call settimer from the body
OnLoad handler to run it) that pops up a dialog like "Your session will
be timed out in 30 seconds. Cancel the timeout [Yes] [No]", which will
do a reload on that page if they choose to cancel the timeout.