Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Each time <a href="http://php.net/session_start" rel="noreferrer">session_start</a> is called the session files timestamp (if it exists) gets updated, which is used to calculated if session.gc_maxlifetime has been exceeded.</p> <p>More importantly you can't depend on a session to expire after session.gc_maxlifetime time has been exceeded. </p> <p>PHP runs garbage collection on expired sessions after the current session is loaded and by using <a href="http://php.net/manual/en/session.configuration.php#ini.session.gc-probability" rel="noreferrer">session.gc_probability</a> and <a href="http://php.net/manual/en/session.configuration.php#ini.session.gc-divisor" rel="noreferrer">session.gc_divisor</a> it calculates the probability that garbage collection will run. By default its a 1% probability.</p> <p>If you have a low number of visitors there is a probability that an inactive user could access a session that should have expired and been deleted. If this is important to you will need to store a timestamp in the session and calculate how log a user has been inactive.</p> <p>This example replaces <a href="http://php.net/session_start" rel="noreferrer">session_start</a> and enforces a timeout:</p> <pre><code>function my_session_start($timeout = 1440) { ini_set('session.gc_maxlifetime', $timeout); session_start(); if (isset($_SESSION['timeout_idle']) &amp;&amp; $_SESSION['timeout_idle'] &lt; time()) { session_destroy(); session_start(); session_regenerate_id(); $_SESSION = array(); } $_SESSION['timeout_idle'] = time() + $timeout; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload