Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP sessions default timeout [duplicate]

Do PHP sessions timeout by default - ie without any coding on my part would a user eventually be "logged out" after some time of inactivity?

like image 955
KB. Avatar asked Mar 28 '12 08:03

KB.


People also ask

What is the default timeout for any php session?

1440 seconds is the default which is actually 24 minutes.

How long is php session timeout?

By default, the PHP session expired when you close the browser or after a specific time. That usually is 24 minutes, but it depends on your server configuration.

How do I expire a php session after 30 minutes?

if you want to expire the session after 30 minutes of activity instead of after 30 minutes since start, you'll also need to use setcookie with an expire of time()+60*30 to keep the session cookie active.

How long is a php session valid?

By default, session variables last until the user closes the browser. So; Session variables hold information about one single user, and are available to all pages in one application. Tip: If you need a permanent storage, you may want to store the data in a database.


2 Answers

It depends on the server configuration or the relevant directives session.gc_maxlifetime in php.ini.

Typically the default is 24 minutes (1440 seconds), but your webhost may have altered the default to something else.

like image 169
Niet the Dark Absol Avatar answered Sep 25 '22 02:09

Niet the Dark Absol


You can change it in you php-configuration on your webserver. Search in php.ini for

session.gc_maxlifetime() The value is set in Seconds.

like image 28
suther Avatar answered Sep 26 '22 02:09

suther