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/begin.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

33 lines
1,004 B
PHP

<?php
require_once 'update.php';
//The time after which an account must be regenerated.
define('ACCOUNT_REGENERATE_TIMER', 10*60);
// Time after which every request must be blocked for a running session.
define('ACCOUNT_EXPIRE_TIMER', ACCOUNT_REGENERATE_TIMER + 1*60);
// For permissions, use the user permissions through $_SESSION or
// use one of the ACCOUNT_PRIV_* const. from session/config.php
function start_new_session(
string $username,
string $displayname,
string $email,
string $permissions
): void
{
//Just checking if the user did have a session previously open.
if(isset($_SESSION["loggedin"]))
{
regenerate_current_session(true);
}
// SESSION VARIABLE ULTIMATE GUIDE !
$_SESSION["username"] = $username;
$_SESSION["displayname"] = $displayname;
$_SESSION["email"] = $email;
$_SESSION["permissions"] = $permissions;
$_SESSION["loggedin"] = true;
$_SESSION["REGENERATETIME"] = time() + ACCOUNT_REGENERATE_TIMER;
$_SESSION['EXPIRES'] = time() + ACCOUNT_EXPIRE_TIMER;
}