Skip to content

Commit

Permalink
Update Session.php
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored Jul 19, 2023
1 parent 29abb49 commit a8d2bec
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Protocols/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ class Session
*/
protected $_sessionId = null;

/**
* Is safe.
*
* @var bool
*/
protected $_isSafe = true;

/**
* Session constructor.
*
Expand Down Expand Up @@ -402,13 +409,25 @@ public function gc()
static::$_handler->gc(static::$lifetime);
}

/**
* __wakeup.
* @return void
*/
public function __wakeup()
{
$this->_isSafe = false;
}

/**
* __destruct.
*
* @return void
*/
public function __destruct()
{
if (!$this->_isSafe) {
return;
}
$this->save();
if (\rand(1, static::$gcProbability[1]) <= static::$gcProbability[0]) {
$this->gc();
Expand Down

0 comments on commit a8d2bec

Please sign in to comment.