27 lines
867 B
PHP
27 lines
867 B
PHP
<?php
|
|
|
|
if ( php_sapi_name() == "cli" ) exit();
|
|
|
|
// Start the session
|
|
session_name(SESSNAME);
|
|
ini_set("session.cookie_samesite", "Lax");
|
|
session_start();
|
|
|
|
// The session variable for the current user
|
|
if ( !isset($_SESSION['userid']) ) $_SESSION['userid'] = 0;
|
|
|
|
// The sesion variable for the currently displayed album
|
|
if ( !isset($_SESSION['currentalbum']) ) $_SESSION['currentalbum'] = 0;
|
|
|
|
// Validate the user from a valid cookie if one exists
|
|
if ( isset($_COOKIE[User::COOKIENAME]) && ($_SESSION['userid'] == 0) ) {
|
|
$cid = User::validateUserCookie($_COOKIE[User::COOKIENAME]);
|
|
if ( $cid != 0 ) {
|
|
$user = new User($cid);
|
|
$_SESSION['userid'] = $cid;
|
|
redirectPage("index.php");
|
|
} else {
|
|
setcookie(User::COOKIENAME, "", array('expires' => time() - 3600, 'path' => "/", 'domain' => $_SERVER['SERVER_NAME'], 'samesite' => 'Lax'));
|
|
}
|
|
}
|