forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 31639: redirect loop when session expireds
- Loading branch information
1 parent
56b3ec3
commit bc8d4ab
Showing
3 changed files
with
27 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of ILIAS, a powerful learning management system | ||
* published by ILIAS open source e-Learning e.V. | ||
|
@@ -18,6 +16,8 @@ | |
* | ||
*********************************************************************/ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @author Alex Killing <[email protected]> | ||
* | ||
|
@@ -226,9 +226,9 @@ public static function _exists(string $a_session_id): bool | |
/** | ||
* Destroy session | ||
* | ||
* @param string|array session id|s | ||
* @param int closing context | ||
* @param int|bool expired at timestamp | ||
* @param string|array $a_session_id session id|s | ||
* @param int|null $a_closing_context closing context | ||
* @param int|bool $a_expired_at expired at timestamp | ||
*/ | ||
public static function _destroy($a_session_id, ?int $a_closing_context = null, $a_expired_at = null): bool | ||
{ | ||
|
@@ -258,6 +258,18 @@ public static function _destroy($a_session_id, ?int $a_closing_context = null, $ | |
|
||
$ilDB->manipulate($q); | ||
|
||
try { | ||
// only delete session cookie if it is set in the current request | ||
if ($DIC->http()->wrapper()->cookie()->has(session_name()) && | ||
$DIC->http()->wrapper()->cookie()->retrieve(session_name(), $DIC->refinery()->kindlyTo()->string()) === $a_session_id) { | ||
$cookieJar = $DIC->http()->cookieJar()->without(session_name()); | ||
$cookieJar->renderIntoResponseHeader($DIC->http()->response()); | ||
} | ||
} catch (\Throwable $e) { | ||
// ignore | ||
// this is needed for "header already" sent errors when the random cleanup of expired sessions is triggered | ||
} | ||
|
||
return true; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters