/var/www/bus-projects/kirby/src/Session/FileSessionStore.php
'fallback' => 'Cannot write to session "' . $name . '", because it is not locked',
'translate' => false,
'httpCode' => 500
]);
}
// delete all file contents first
if (rewind($handle) !== true || ftruncate($handle, 0) !== true) {
// @codeCoverageIgnoreStart
throw new Exception([
'key' => 'session.filestore.unexpectedFilesystemError',
'fallback' => 'Unexpected file system error',
'translate' => false,
'httpCode' => 500
]);
// @codeCoverageIgnoreEnd
}
// write the new contents
$result = fwrite($handle, $data);
if (!is_int($result) || $result === 0) {
// @codeCoverageIgnoreStart
throw new Exception([
'key' => 'session.filestore.unexpectedFilesystemError',
'fallback' => 'Unexpected file system error',
'translate' => false,
'httpCode' => 500
]);
// @codeCoverageIgnoreEnd
}
}
/**
* Deletes the given session
*
* Needs to throw an Exception on error.
*
* @param int $expiryTime Timestamp
* @param string $id Session ID
* @return void
/var/www/bus-projects/kirby/src/Session/FileSessionStore.php
'fallback' => 'Cannot write to session "' . $name . '", because it is not locked',
'translate' => false,
'httpCode' => 500
]);
}
// delete all file contents first
if (rewind($handle) !== true || ftruncate($handle, 0) !== true) {
// @codeCoverageIgnoreStart
throw new Exception([
'key' => 'session.filestore.unexpectedFilesystemError',
'fallback' => 'Unexpected file system error',
'translate' => false,
'httpCode' => 500
]);
// @codeCoverageIgnoreEnd
}
// write the new contents
$result = fwrite($handle, $data);
if (!is_int($result) || $result === 0) {
// @codeCoverageIgnoreStart
throw new Exception([
'key' => 'session.filestore.unexpectedFilesystemError',
'fallback' => 'Unexpected file system error',
'translate' => false,
'httpCode' => 500
]);
// @codeCoverageIgnoreEnd
}
}
/**
* Deletes the given session
*
* Needs to throw an Exception on error.
*
* @param int $expiryTime Timestamp
* @param string $id Session ID
* @return void
/var/www/bus-projects/kirby/src/Session/Session.php
'newSession' => $this->newSession
];
} else {
$data = [
'startTime' => $this->startTime(),
'expiryTime' => $this->expiryTime(),
'duration' => $this->duration(),
'timeout' => $this->timeout(),
'lastActivity' => $this->lastActivity,
'renewable' => $this->renewable(),
'data' => $this->data()->get()
];
}
// encode the data and attach an HMAC
$data = serialize($data);
$data = hash_hmac('sha256', $data, $this->tokenKey) . "\n" . $data;
// store the data
$this->sessions->store()->set($this->tokenExpiry, $this->tokenId, $data);
$this->sessions->store()->unlock($this->tokenExpiry, $this->tokenId);
$this->writeMode = false;
}
/**
* Entirely destroys the session
*
* @return void
*/
public function destroy()
{
// no need to destroy new or destroyed sessions
if ($this->tokenExpiry === null || $this->destroyed === true) {
return;
}
// remove session file
$this->sessions->store()->destroy($this->tokenExpiry, $this->tokenId);
$this->destroyed = true;
$this->writeMode = false;