Genadinik
Genadinik

Reputation: 18649

Apache making the session time out longer

I already altered my php.ini in Apache to have these settings:

session.gc_maxlifetime = 1440
session.cache_expire = 1500

But my sessions are not that long. The problem is that I am not certain which settings would "do the trick"

Ideally I am looking for the right configuration to have the session last 12 hours. Could anyone help me with that?

Upvotes: 9

Views: 63886

Answers (3)

SuprMan
SuprMan

Reputation: 380

session.gc_maxlifetime is measured in seconds, so your setting of 1440 will expire after 24 minutes. (see: http://php.net/session.gc-maxlifetime)

For 12 hour session I believe you need:

session.gc_maxlifetime = 43200
session.cache_expire = 720
session.cookie_lifetime = 0 

Upvotes: 3

Inna
Inna

Reputation: 367

do you also have set session.cookie_lifetime = 0 ? and maybe somewhere in your scripts or some included scripts the session lifetime is set to another value?

The default "0" value means that the cookie stays alive until the browser is closed. This is also the default value, if not set in php.ini. Source: http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime

Upvotes: 11

rzetterberg
rzetterberg

Reputation: 10268

Have a look at:

session.cookie_lifetime x

Where x is the lifetime in seconds

Also, if you are on a shared host, make sure the session data under /tmp is not removed by the host with some sort of clean script. Some hosts clear /tmp every 10 minutes.

Upvotes: 1

Related Questions