Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the default lifetime of a session?

Tags:

php

session

If I hit a page which calls session_start(), how long would I have to wait before I get a new session ID when I refresh the page?

like image 555
Greg B Avatar asked Oct 01 '08 08:10

Greg B


People also ask

What is the lifetime of a session?

Session lifetime determines the maximum idle time of an end user's sign-on session to Okta. Lowering this value decreases the risk of malicious third party access to a user's applications from an active session. The maximum time allowed time for this setting is 90 days.

What is the default expire time of session?

The Default Expiration Period for Session is 20 Minutes. The Default Expiration Period for Cookie is 30 Minutes.

What is the default time in session variable?

NET stack the default session timeout is 20 minutes. You can change the session timeout via IIS or instead you can use Factory Configuration. You can read more about session variables here.

How do you set a lifetime session?

For set the time life in php, you can use the function session_set_cookie_params, before the session_start: session_set_cookie_params(3600,"/"); session_start(); For ex, 3600 seconds is one hour, for 2 hours 3600*2 = 7200.


1 Answers

Check out php.ini the value set for session.gc_maxlifetime is the ID lifetime in seconds.

I believe the default is 1440 seconds (24 mins)

http://www.php.net/manual/en/session.configuration.php

Edit: As some comments point out, the above is not entirely accurate. A wonderful explanation of why, and how to implement session lifetimes is available here:

How do I expire a PHP session after 30 minutes?

like image 145
Martin Avatar answered Oct 18 '22 10:10

Martin