Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple session start calls #36239

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lib/private/Session/Internal.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ public function remove(string $key) {
}

public function clear() {
$this->reopen();
$this->invoke('session_unset');
$this->regenerateId();
$this->startSession(true);
$this->invoke('session_unset');
$_SESSION = [];
}

Expand Down Expand Up @@ -178,9 +176,7 @@ public function getId(): string {
*/
public function reopen(): bool {
if ($this->sessionClosed) {
$this->startSession(false, false);
$this->sessionClosed = false;
return true;
return $this->startSession(false);
}

return false;
Expand Down Expand Up @@ -225,11 +221,18 @@ private function invoke(string $functionName, array $parameters = [], bool $sile
}
}

private function startSession(bool $silence = false, bool $readAndClose = true) {
/**
* @return bool
*/
private function startSession(bool $readAndClose = true) {
$sessionParams = ['cookie_samesite' => 'Lax'];
if (\OC::hasSessionRelaxedExpiry()) {
$sessionParams['read_and_close'] = $readAndClose;
}
$this->invoke('session_start', [$sessionParams], $silence);
if ($this->invoke('session_start', [$sessionParams])) {
$this->sessionClosed = !empty($sessionParams['read_and_close']);
the-djmaze marked this conversation as resolved.
Show resolved Hide resolved
return true;
}
return false;
}
}