Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long will my session last?

Can someone please tell me how long my session will last from the data below? - I'm not sure which one tells me

session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn On  On
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   /var/lib/php/session    /var/lib/php/session
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    Off Off
session.use_trans_sid   0   0
like image 973
Keith Donegan Avatar asked Oct 04 '09 12:10

Keith Donegan


People also ask

How long should sessions last?

If you're going for individual counseling, then your session will last approximately 50-55 minutes. This 50-55 minutes is referred to as a "therapeutic hour." This is standard practice, although some clinicians will offer 45-minute sessions or 60-minute sessions.

How long does a session ID last?

Yes the Session cookie expires. In addition to the 30 minute default timeout (if the visitor is idle for 30 minutes) the 'Session ID' cookie will expire at the end of an internet browser session.

How long is a session php?

By default, a session lasts until the user closes his browser. This option can be changed in the php. ini file on the web server by changing the 0 in session. cookie_lifetime = 0 to the number of seconds you want the session to last or by using session_set_cookie_params().

How long does a Java session last?

Session timeout determines how long the server maintains a session if a user does not explicitly invalidate the session. The default value is 30 minutes.


4 Answers

In general you can say session.gc_maxlifetime specifies the maximum lifetime since the last change of your session data (not the last time session_start was called!). But PHP’s session handling is a little bit more complicated.

Because the session data is removed by a garbage collector that is only called by session_start with a probability of session.gc_probability devided by session.gc_divisor. The default values are 1 and 100, so the garbage collector is only started in only 1% of all session_start calls. That means even if the the session is already timed out in theory (the session data had been changed more than session.gc_maxlifetime seconds ago), the session data can be used longer than that.

Because of that fact I recommend you to implement your own session timeout mechanism. See my answer to How do I expire a PHP session after 30 minutes? for more details.

like image 140
Gumbo Avatar answered Sep 28 '22 23:09

Gumbo


This is the one. The session will last for 1440 seconds (24 minutes).

session.gc_maxlifetime  1440    1440
like image 29
Lukáš Lalinský Avatar answered Sep 30 '22 23:09

Lukáš Lalinský


You're searching for gc_maxlifetime, see http://php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime for a description.

Your session will last 1440 seconds which is 24 minutes (default).

like image 20
svens Avatar answered Oct 02 '22 23:10

svens


If session.cookie_lifetime is 0, the session cookie lives until the browser is quit.

EDIT: Others have mentioned the session.gc_maxlifetime setting. When session garbage collection occurs, the garbage collector will delete any session data that has not been accessed in longer than session.gc_maxlifetime seconds. To set the time-to-live for the session cookie, call session_set_cookie_params() or define the session.cookie_lifetime PHP setting. If this setting is greater than session.gc_maxlifetime, you should increase session.gc_maxlifetime to a value greater than or equal to the cookie lifetime to ensure that your sessions won't expire.

like image 22
Øystein Riiser Gundersen Avatar answered Oct 01 '22 23:10

Øystein Riiser Gundersen