Session Problem

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
k1ndkam
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2003 1:52 am

Session Problem

Post by k1ndkam »

i wanted to know is there a way to set session time out in php because i am developing a user authentication system where if the user presses log out then the session could be destroyed but if the user does not press it then how long will it take to log out and again sign in and how can i anage this problem .
Thanks
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

What kind of sessions are you using ? Cookies or database ?

Regards,
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

The standard session time out in php is set to "until the browser is closed." If you want to set this to something different you should first read the php manual http://php.net/manual/en/ref.session.php - there's a lot about the things you're asking
k1ndkam
Forum Newbie
Posts: 2
Joined: Thu Jun 12, 2003 1:52 am

Post by k1ndkam »

My session files are saved in temp directory and I am talking about cookies i also wanted to know how these files could be deleted automatically after session ends.

Regards
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

delorian's link to the manual page explains exactly what you need, but dependant on the OS you are using you may have issues.

The session_destroy() method should clean up your expired sessions, the default TTL is 1440 seconds.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

which doesn't mean the files vanish instantly after 1440 seconds.
How often php searches for old session files is controlled via session.gc_probability
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

Very true.
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

cactus wrote:
The session_destroy() method should clean up your expired sessions, the default TTL is 1440 seconds.
Yes session_destroy() works great but instead of just going back to the index page or whatever I refresh to a kill page after destroying it. Then it refreshes to the page I want it to go to. This way You can not hit the back button and still have session.
Post Reply