VaTo
VaTo

Reputation: 3078

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

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?

Upvotes: 4

Views: 13753

Answers (1)

Nitin
Nitin

Reputation: 916

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.

Upvotes: 8

Related Questions