Skip to content
Draft
Changes from all 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
9 changes: 9 additions & 0 deletions Sources/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,20 @@ public function read(string $session_id): string
*/
public function write(string $session_id, string $data): bool
{
// Any action that is not dependent on data within the session may be added to this array
static $no_writes = ['dlattach'];

// Don't bother writing the session if cookies are disabled
if (empty($_COOKIE)) {
return true;
}

// Don't bother writing the session for users just browsing
// If verification is required, always write the session
if ((empty($_REQUEST['action']) || \in_array($_REQUEST['action'], $no_writes, true)) && !empty(Config::$scripturl) && empty(Utils::$context['require_verification'])) {
return true;
}

if (preg_match('~^[A-Za-z0-9,-]{16,64}$~', $session_id) == 0) {
return false;
}
Expand Down
Loading