Files

47 lines
889 B
PHP
Raw Permalink Normal View History

2026-08-20 16:01:58 +00:00
<?php
declare(strict_types=1);
/*
* =========================================================
* SESSION
* =========================================================
*/
session_set_cookie_params([
'lifetime' => 0,
'path' => '/',
'secure' => !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off',
'httponly' => true,
'samesite' => 'Strict'
]);
session_start();
/*
* =========================================================
* VERIFICATION AUTHENTIFICATION
* =========================================================
*/
if (
empty($_SESSION['user_id']) ||
empty($_SESSION['authenticated'])
) {
http_response_code(401);
header(
'Content-Type: application/json; charset=utf-8'
);
echo json_encode([
'success' => false,
'message' => 'Authentification requise.'
], JSON_UNESCAPED_UNICODE);
exit;
}