Add cookie for compath so it recovers from a login expiration better

This commit is contained in:
Junior 2026-11-08 12:10:29 -05:00
parent 6afdaeda78
commit a3765e8eee
3 changed files with 17 additions and 3 deletions

View File

@ -34,7 +34,13 @@ function compareNames($a, $b) {
$adultcomics = getAdultComics(); $adultcomics = getAdultComics();
$compath = $_SESSION['compath']; $compath = $_SESSION['compath'];
$fullcompath = COMICSDIR . (($compath == "/") ? "" : $compath) . "/"; $fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
if ( !is_dir($fullcompath) ) {
$compath = "/";
$fullcompath = COMICSDIR . $compath . (($compath == "/") ? "" : "/") . "/";
$_SESSION['compath'] = $compath;
setcookie("compath", $compath, time()+31536000, "/", "jaj.com", true);
}
// Build up a list of comics and issues which have been read in descending order by lastupdate // Build up a list of comics and issues which have been read in descending order by lastupdate
$query = "SELECT comic, issue FROM pagetracker WHERE username=:username"; $query = "SELECT comic, issue FROM pagetracker WHERE username=:username";

View File

@ -27,6 +27,7 @@ if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strle
} else { } else {
$_SESSION['compath'] = substr($comicfull, strlen(COMICSDIR)); $_SESSION['compath'] = substr($comicfull, strlen(COMICSDIR));
} }
setcookie("compath", $_SESSION['compath'], time()+31536000, "/", "jaj.com", true);
$data["message"] = "New comic path: {$_SESSION["compath"]}"; $data["message"] = "New comic path: {$_SESSION["compath"]}";
$pathparts = pathinfo($_SESSION['compath']); $pathparts = pathinfo($_SESSION['compath']);

View File

@ -23,9 +23,16 @@ if ( php_sapi_name() != "cli" ) {
// This session variable is set to the current browsing folder. // This session variable is set to the current browsing folder.
// It is relative to the COMICSDIR constant defined in config.php // It is relative to the COMICSDIR constant defined in config.php
if ( !isset($_SESSION['compath']) ) { if ( !isset($_SESSION['compath']) ) {
$_SESSION['compath'] = '/'; if ( isset($_COOKIE['compath']) ) {
$_SESSION['compath'] = $_COOKIE['compath'];
} else {
$_SESSION['compath'] = '/';
}
}
if ( $_SESSION['compath'] == "" ) {
$_SESSION['compath'] = "/";
setcookie("compath", $_SESSION['compath'], time()+31536000, "/", "jaj.com", true);
} }
if ( $_SESSION['compath'] == "" ) $_SESSION['compath'] = "/";
// This session variable is set to the current comic in Base64 // This session variable is set to the current comic in Base64
if ( !isset($_SESSION['comfile']) ) { if ( !isset($_SESSION['comfile']) ) {