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

Added data unset to stop data being read from outdated cookie #47

Merged
merged 6 commits into from
Feb 7, 2019
Merged
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
24 changes: 20 additions & 4 deletions src/Store/CookieStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,27 @@ protected function canWrite()

public function write($session_id, $session_data)
{
$canWrite = $this->canWrite();
$isExceedingCookieLimit = (strlen($session_data) > static::config()->get('max_length'));
$crypto = $this->getCrypto($session_id);

// Check ability to safely encrypt and write content
if (!$this->canWrite()
|| (strlen($session_data) > static::config()->get('max_length'))
|| !($crypto = $this->getCrypto($session_id))
) {
if (!$canWrite || $isExceedingCookieLimit || !$crypto) {
if ($canWrite && $isExceedingCookieLimit) {
$params = session_get_cookie_params();
// Clear stored cookie value and cookie when length exceeds the set limit
$this->currentCookieData = null;
Cookie::set(
$this->cookie,
'',
0,
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
}
gelysis marked this conversation as resolved.
Show resolved Hide resolved

return false;
}

Expand Down