Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make a php session to never expire (in the conf file, no code)

Tags:

php

session

I would like to manage the time that a session expire to be forever.

What do I have to change In the php configuration file so this change is permanent and I don't have to implement this in all the code I write?

After I make a change in the php file, do I need to restart apache for the changes to take effect?

like image 502
VaTo Avatar asked Oct 28 '25 00:10

VaTo


1 Answers

It is not possible to store the session infinitely unless you do not use garbage collection in php. You could try to set the php ini settings and set the time to 10 years

// set the max life time, after this, session is seen as garbage
session.gc_maxlifetime=315360000

If you have cookies enabled:

session.use_cookies=1
#session.use_only_cookies=1

// set the cookie expiration as well
session.cookie_lifetime=315360000

To avoid Int overflow, do not use a value larger than 2,147,483,647 as this is the max an Int32 can hold.

like image 90
Nitin Avatar answered Oct 29 '25 13:10

Nitin