Get php server session timeout

I want to get the session.gc_maxlifetime value from the PHP server settings (the time during which the session expires after inactivity). It is very important: I do not want to change it, I only want to get its value (maybe the value is different from server to server), and I want to use the PHP script that I did to warn users correctly, depending on the settings of this server.

Thanks.

+7
source share
2 answers

What happens with the ini_get function:

 $maxlifetime = ini_get("session.gc_maxlifetime"); 

From the manual we read:

session.gc_maxlifetime integer session.gc_maxlifetime indicates the number of seconds after which data will be considered garbage and potentially cleared. Garbage collection may occur during a session (depending on session.gc_probability and session.gc_divisor).

+19
source

session.gc_maxlifetime is not the session end time after inactivity. gc here might be average junk. Since php manual says

session.gc_maxlifetime indicates the number of seconds after which data will be considered garbage and potentially cleared. garbage collection may occur during the session (depending on session.gc_probability and session.gc_divisor).

Note. If different scripts have different session.gc_maxlifetime values, but use the same place to store session data, then a script with a minimum value will clear the data. In this case, use this directive with session.save_path.

See the message for details.

0
source

All Articles