From a3765e8eeefe8c6ff7fedfef80908542b5def6a4 Mon Sep 17 00:00:00 2001 From: Junior Date: Sun, 8 Nov 2026 12:10:29 -0500 Subject: [PATCH] Add cookie for compath so it recovers from a login expiration better --- ajax/getfoldercontents.php | 8 +++++++- ajax/setpath.php | 1 + header.php | 11 +++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ajax/getfoldercontents.php b/ajax/getfoldercontents.php index ba29a90..aba92a8 100644 --- a/ajax/getfoldercontents.php +++ b/ajax/getfoldercontents.php @@ -34,7 +34,13 @@ function compareNames($a, $b) { $adultcomics = getAdultComics(); $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 $query = "SELECT comic, issue FROM pagetracker WHERE username=:username"; diff --git a/ajax/setpath.php b/ajax/setpath.php index 4e38ec3..d1eccf0 100644 --- a/ajax/setpath.php +++ b/ajax/setpath.php @@ -27,6 +27,7 @@ if ( ($newpath == "/") || ($comicfull === false) || (substr($comicfull, 0, strle } else { $_SESSION['compath'] = substr($comicfull, strlen(COMICSDIR)); } +setcookie("compath", $_SESSION['compath'], time()+31536000, "/", "jaj.com", true); $data["message"] = "New comic path: {$_SESSION["compath"]}"; $pathparts = pathinfo($_SESSION['compath']); diff --git a/header.php b/header.php index 7085a82..ae807be 100644 --- a/header.php +++ b/header.php @@ -23,9 +23,16 @@ if ( php_sapi_name() != "cli" ) { // This session variable is set to the current browsing folder. // It is relative to the COMICSDIR constant defined in config.php 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 if ( !isset($_SESSION['comfile']) ) {