session de connexion 1 mois

This commit is contained in:
Esenjin 2025-02-14 23:35:20 +01:00
parent 78a165d103
commit c44b0bc223

View File

@ -1,4 +1,15 @@
<?php
ini_set('session.gc_maxlifetime', 30 * 24 * 60 * 60); // 30 jours en secondes
ini_set('session.cookie_lifetime', 30 * 24 * 60 * 60);
session_set_cookie_params([
'lifetime' => 30 * 24 * 60 * 60,
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'Strict'
]);
session_start();
class Config {
@ -19,17 +30,4 @@ class Config {
$config = self::load();
return $config[$key] ?? $default;
}
public static function save($config) {
$configFile = __DIR__ . '/../config.json';
$jsonContent = json_encode($config, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
if (file_put_contents($configFile, $jsonContent) === false) {
throw new Exception('Impossible de sauvegarder la configuration');
}
self::$config = $config;
return true;
}
}