how to regenerate session id before expire in php code example
Example 1: php session regenerate id
<?php
session_start();
$old_sessionid = session_id();
session_regenerate_id();
$new_sessionid = session_id();
echo "Old Session: $old_sessionid<br />";
echo "New Session: $new_sessionid<br />";
?>
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();