Expiration of session variables?

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
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Expiration of session variables?

Post by spacebiscuit »

Hi,

How long do session variables last for.

The reason I ask is because if I return to my sript that uses them they are still active even though I haven't called the script for a few hours.Do they expire after a period or is it necessary to kill them?

I thought to perhaps use a 'log-off' button to kill the session variables, is this necessary?

Is this a concern for the server's memory?

Thanks,

Rob.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

they stick around in the browser until you close all instances of the browser (typically). Depending on server settings, and where you store the session data, the actual data behind the session may be destroyed after a time. But that depends on your settings.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I do know that sessions expire after a certain period of time if there is no activity.
I do not know how long though however.
php_wiz_kid
Forum Contributor
Posts: 181
Joined: Tue Jun 24, 2003 7:33 pm

Post by php_wiz_kid »

A session by default is set to 180 minutes. Youc can change this in your php.ini file or you can use the session_cache_expire() function to set the sessions expiration time. Check out the PHP docs for more info. I hope this helps.
Post Reply