Session handling

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
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Session handling

Post by aceconcepts »

Hi,

How would I destroy/end a visitor's session after a particular period?

And, how would I make their session last longer than the default 1440?

Thanks.
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

You can use session_destroy() to remove user session i.e. when he clicks LOGOUT button.

php kills session automatically after some time.
You can define it in php.ini:
session.gc_maxlifetime
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Post by aceconcepts »

I don't have access to the php ini file. How can I destroy the session after a period e.g. 1minute (just to test it).
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

This should work (on top of the page before you start a session):

Code: Select all

ini_set('session.gc_maxlifetime', 60);
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

There are some other issues with changing session timeout
check this website out http://www.captain.at/howto-php-sessions.php
Post Reply