accueil: supprimer la persistence de catégorie par cookie
This commit is contained in:
+1
-22
@@ -2138,28 +2138,7 @@ switch ($action) {
|
|||||||
$privateCats = $articles->getPrivateCategories();
|
$privateCats = $articles->getPrivateCategories();
|
||||||
$allCats = $articles->getCategories();
|
$allCats = $articles->getCategories();
|
||||||
|
|
||||||
if (array_key_exists('cat', $_GET)) {
|
$filterCat = array_key_exists('cat', $_GET) ? trim($_GET['cat']) : '';
|
||||||
$filterCat = trim($_GET['cat']);
|
|
||||||
if ($filterCat === '') {
|
|
||||||
// Réinitialisation explicite → effacer le cookie et rediriger
|
|
||||||
setcookie('varlog_cat', '', time() - 3600, '/', '', $isHttps, true);
|
|
||||||
header('Location: /', true, 302);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
// Sauvegarder la catégorie choisie (1 an)
|
|
||||||
setcookie('varlog_cat', $filterCat, time() + 365 * 24 * 3600, '/', '', $isHttps, true);
|
|
||||||
} else {
|
|
||||||
// Pas de paramètre → appliquer le cookie si la catégorie existe toujours
|
|
||||||
$savedCat = trim($_COOKIE['varlog_cat'] ?? '');
|
|
||||||
if ($savedCat !== '' && isset($allCats[$savedCat])) {
|
|
||||||
header('Location: /categorie/' . rawurlencode($savedCat), true, 302);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if ($savedCat !== '' && !isset($allCats[$savedCat])) {
|
|
||||||
setcookie('varlog_cat', '', time() - 3600, '/', '', $isHttps, true);
|
|
||||||
}
|
|
||||||
$filterCat = '';
|
|
||||||
}
|
|
||||||
$allPosts = array_values(array_filter($articles->getAll(), static function (array $a) use ($privateCats, $filterCat): bool {
|
$allPosts = array_values(array_filter($articles->getAll(), static function (array $a) use ($privateCats, $filterCat): bool {
|
||||||
if (!$a['published']) {
|
if (!$a['published']) {
|
||||||
return canDoOnArticle('view_drafts', $a);
|
return canDoOnArticle('view_drafts', $a);
|
||||||
|
|||||||
Reference in New Issue
Block a user