php session time code example
Example 1: php session time out default
The default lifetime of a session in PHP is 1440 seconds, or 24 minutes
Example 2: php expire a session
$minutesBeforeSessionExpire=30;
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > ($minutesBeforeSessionExpire*60))) {
session_unset();
session_destroy();
}
$_SESSION['LAST_ACTIVITY'] = time();
Example 3: default time of session in php
24 minutes
It depends on the server configuration or the relevant directives session. gc_maxlifetime in php. ini . Typically the default is 24 minutes (1440 seconds), but your webhost may have altered the default to something else