31 lines
585 B
PHP
31 lines
585 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
ini_set('session.use_only_cookies' , 1);
|
|
ini_set('session.use_strict_mode' , 1);
|
|
|
|
session_set_cookie_params([
|
|
'lifetime' => 1800,
|
|
'domain' => 'ethernal.win',
|
|
'path' => '/',
|
|
'secure' => true,
|
|
'httponly' => true
|
|
]);
|
|
|
|
session_start();
|
|
|
|
if ( !isset($_SESSION["last_regen"]) ){
|
|
session_regen();
|
|
|
|
} else {
|
|
$timeout_m = 60 * 30; // 30 minutes
|
|
if ((time() - $_SESSION["last_regen"]) > $timeout_m) {
|
|
session_regen();
|
|
}
|
|
}
|
|
|
|
function session_regen() {
|
|
session_regenerate_id();
|
|
$_SESSION["last_regen"] = time();
|
|
} |