I am creating a session when a user logs in like so:
$_SESSION['id'] = $id;
How can I specify a timeout on that session of X minutes and then have it perform a function or a page redirect once it has reached X minutes??
EDIT: I forgot to mention that I need the session to timeout due to inactivity.
In the header of every page has been working for me during site tests(the site is not yet in production). The HTML page it falls to ends the session and just informs the user of the need to log in again. This seems an easier way than playing with PHP logic. I'd love some comments on the idea. Any traps I havent seen in it ?
source: http://www.daniweb.com/web-development/php/threads/124500
first, store the last time the user made a request
in subsequent request, check how long ago they made their previous request (10 minutes in this example)
Just check first the session is not already created and if not create one. Here i am setting it for 1 minute only.