Skip to content

Commit

Permalink
Auth: Don't send HTTP cookies in non-HTTP processes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansenDatabay committed Feb 5, 2025
1 parent 5d879ce commit ef67329
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Services/Authentication/classes/class.ilSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,21 @@ 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());
if (ilContext::usesHTTP()) {
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
}
} catch (\Throwable $e) {
// ignore
// this is needed for "header already" sent errors when the random cleanup of expired sessions is triggered
}

return true;
Expand Down

0 comments on commit ef67329

Please sign in to comment.