Skip to content
Permalink
Browse files

Session: $started changed from static to object property

  • Loading branch information...
dg committed Mar 11, 2019
1 parent 4a2bb60 commit 34946ca6895cfcb51530f20508e438d98ea82a82
Showing with 10 additions and 10 deletions.
  1. +10 −10 src/Http/Session.php
@@ -26,7 +26,7 @@ class Session
private $regenerated = false;
/** @var bool has been session started by Nette? */
private static $started = false;
private $started = false;
/** @var array default configuration */
private $options = [
@@ -72,7 +72,7 @@ public function __construct(IRequest $request, IResponse $response)
public function start(): void
{
if (session_status() === PHP_SESSION_ACTIVE) {
if (!self::$started) {
if (!$this->started) {
$this->initialize();
}
return;
@@ -107,7 +107,7 @@ public function start(): void
private function initialize(): void
{
self::$started = true;
$this->started = true;
/* structure:
__NF: Data, Meta, Time
@@ -154,7 +154,7 @@ private function initialize(): void
*/
public function isStarted(): bool
{
return self::$started && session_status() === PHP_SESSION_ACTIVE;
return $this->started && session_status() === PHP_SESSION_ACTIVE;
}
@@ -166,7 +166,7 @@ public function close(): void
if (session_status() === PHP_SESSION_ACTIVE) {
$this->clean();
session_write_close();
self::$started = false;
$this->started = false;
}
}
@@ -182,7 +182,7 @@ public function destroy(): void
session_destroy();
$_SESSION = null;
self::$started = false;
$this->started = false;
if (!$this->response->isSent()) {
$params = session_get_cookie_params();
$this->response->deleteCookie(session_name(), $params['path'], $params['domain'], $params['secure']);
@@ -277,7 +277,7 @@ public function getSection(string $section, string $class = SessionSection::clas
*/
public function hasSection(string $section): bool
{
if ($this->exists() && !self::$started) {
if ($this->exists() && !$this->started) {
$this->start();
}
@@ -290,7 +290,7 @@ public function hasSection(string $section): bool
*/
public function getIterator(): \Iterator
{
if ($this->exists() && !self::$started) {
if ($this->exists() && !$this->started) {
$this->start();
}
@@ -396,7 +396,7 @@ private function configure(array $config): void
} else {
if (session_status() === PHP_SESSION_ACTIVE) {
throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . (self::$started ? '.' : ' by session.auto_start or session_start().'));
throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? '.' : ' by session.auto_start or session_start().'));
}
if (isset($special[$key])) {
$key = "session_$key";
@@ -499,7 +499,7 @@ public function setSavePath(string $path)
*/
public function setHandler(\SessionHandlerInterface $handler)
{
if (self::$started) {
if ($this->started) {
throw new Nette\InvalidStateException('Unable to set handler when session has been started.');
}
$this->handler = $handler;

0 comments on commit 34946ca

Please sign in to comment.
You can’t perform that action at this time.