This repository has been archived on 2026-04-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Project_BDE/www/lib/PHP/session/update.php
smithi_3000 37a2ae2c2d Modified website hierarchy (again !) and files about it.
Everything previously under www/src now are under www/
Moved style.CSS under www/ressources, to allow blocking http requests to
www/lib completly
Moved <head> and <header> generation under lib/PHP/output/sections.php
to reduce redundancy within files. Also implemented a system to allow
them to generate relatif paht for href to ressources depending on their
deepness within www/ hierarchy.
2025-11-16 00:01:32 +01:00

42 lines
1 KiB
PHP

<?php
require_once 'config.php';
session_name($sessionconfig_name);
session_set_cookie_params([
'lifetime' => $sessioncookie_lifetime,
'path' => $sessioncookie_path,
'secure' => $sessioncookie_secure,
'httponly' => $sessioncookie_httponly,
'samesite' => $sessioncookie_samesite
]);
session_start();
// If you consider calling this, ask yourself why.
function regenerate_current_session(bool $force = false): void
{
if($force || $_SESSION["REGENERATETIME"] < time())
{
$_SESSION["EXPIRES"] = time() + 2*60;
session_regenerate_id();
$_SESSION["REGENERATETIME"] = time() + ACCOUNT_REGENERATE_TIMER;
$_SESSION['EXPIRES'] = time() + ACCOUNT_EXPIRE_TIMER;
}
}
// Automaticly called by session/continue.php
function update_session_validity(): bool
{
if(!isset($_SESSION['loggedin'])) { return false; }
if(isset($_SESSION['EXPIRES']) && $_SESSION["EXPIRES"] < time())
{
$_SESSION["loggedin"] = false;
}
if($_SESSION["loggedin"] && $_SESSION["REGENERATETIME"] < time())
{
regenerate_current_session(true);
}
return $_SESSION["loggedin"];
}