Welcome to WebmasterWorld Guest from 34.239.158.107

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Session timeout

     
8:11 pm on May 10, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 28, 2003
posts:104
votes: 0


Please Can you tell me if I want sessions on my website to last for three hours, is this the correct code to use. Can you tell me, if I only need to use it, the first time I create a session or should I use it every time I use session_start.

ini_set('session.gc_maxlifetime',30);
ini_set('session.gc_probability',1);
ini_set('session.gc_divisor',1);

8:22 pm on May 10, 2006 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


Hello...

Why wouldn't you use cookies [us3.php.net]?

eelix

8:31 pm on May 10, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 28, 2003
posts:104
votes: 0


I am not sure. I am using sessions for authentication And I wish to make that authentication last longer. So I figured increase the length of the session. Thanks for the link I'm reading now
8:34 pm on May 10, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15756
votes: 0


well, you don't really need to make it longer, as long as the user stays active on your site the session will stay alive, it is only cleaned up after a set period of inactivity.

if you are looking for persistent logins then you should probably use cookies, or even a combination of cookies and sessions.

2:22 am on May 11, 2006 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12555
votes: 3


eelixduppy, PHP sessions [php.net] do use cookies. Well, they use one of two methods to propagate a session id, one of them being cookies anyway.

The 'gc' in the configuration directives here stand for garbage collection which means cleaning up the session files after a certain period of inactivity, as jatar_k mentioned. It does not necessarily mean that sessions will be cleaned up after the set period of inactivity. It does mean that there is a certain percentage of probability that it will be cleaned up after that period of inactivity. In the example directives shown there is a 100% chance that sessions will be cleaned up every 30 seconds.

The link provided describes the configuration directives in greater detail. Also, here are a couple of other good threads that may be of interest:
session not timing out [webmasterworld.com]
Session is timing out - how do I increase cookie time? [webmasterworld.com]

2:28 am on May 11, 2006 (gmt 0)

Senior Member

joined:Nov 12, 2005
posts:5967
votes: 0


Thanks coopster. I'll have to look into that.

eelix

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members