I've got Session Variables in my web site, but I'm curious about what happens when a user leaves the site. Do the variables destroy themselves after a period of time, or if the user leaves then comes back will the variables still be set. For instance in Java there is a garbage collector.
I'm also curious about the logic if a user is inactive for a while, how can I make it where it will destroy the variables, like sign out the user.
Thanks for sharing the knowledge.
Termination of Session Variables
Moderator: General Moderators
- jdhorton77
- Forum Commoner
- Posts: 56
- Joined: Tue Nov 07, 2006 3:29 pm
- Location: Charlotte, NC
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Sessions are normally tracked by cookie, which (by default) are destroyed when the user closes the browser. On the server side, PHP does "collect the garbage" from time to time (PHP deletes old session files on a probability -- default is 1/100 chance of deletion for every page load).
You can keep track of idle time by setting time() to a session variable, and killing the session if that variable is older than N minutes.
You can keep track of idle time by setting time() to a session variable, and killing the session if that variable is older than N minutes.
- jdhorton77
- Forum Commoner
- Posts: 56
- Joined: Tue Nov 07, 2006 3:29 pm
- Location: Charlotte, NC