Files
synologySsoClientExamplePage/check_lifetime.php
2023-12-22 17:21:31 +01:00

40 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// ------------------------------------------------------------------------------
//
// © Copyright (с) 2023 License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.txt
// Author: Rhttps://github.com/pgmr3
// ------------------------------------------------------------------------------
include_once('config.php');
include_once('check_accesstoken.php');
if(session_status() !== PHP_SESSION_ACTIVE) $name_vorher = session_name (SESSION_NAME); //"ServerTools");
session_start();//repeated start without changing the parameters
if(!isset($_SESSION['endTime']) || !isset($_SESSION['sso_accesstoken']) ) {
header('State:'.'noAccess');
exit();
}
$_SESSION['lifetime'] = $_SESSION['endTime'] - time();//Remaining time
if ($_SESSION['lifetime'] <= 0 ) {
CheckAccesstoken();
if(!isset($_SESSION['sso_accesstoken'])) {
header('location: '.LOCAL_HOST.'/');
header('State:'.'noAccess');
exit();
}
}
else {
header('State:'.'waiting');
//usleep(1000);
}
if(isset($_GET['echoSessionLifetime'])) {
if ($_GET['echoSessionLifetime'] === "true") {
echo "You will be logged out in ".$_SESSION['lifetime']." seconds. Renew with F5/reload site.";
}
else exit();
}
?>