1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-11 17:24:46 +02:00

Update Session API var to add a $session->sessionHandler() method that returns an instance to the current WireSessionHandler instance, or null if using PHP file-based sessions.

This commit is contained in:
Ryan Cramer
2020-09-11 14:23:16 -04:00
parent 2e81d39275
commit 2ed6494494
2 changed files with 38 additions and 1 deletions

View File

@@ -119,6 +119,14 @@ class Session extends Wire implements \IteratorAggregate {
*/
protected $sessionAllow = null;
/**
* Instance of custom session handler module, when in use (null when not)
*
* @var WireSessionHandler|null
*
*/
protected $sessionHandler = null;
/**
* Name of key/index within $_SESSION where PW keeps its session data
*
@@ -1486,5 +1494,22 @@ class Session extends Wire implements \IteratorAggregate {
if(is_null($this->CSRF)) $this->CSRF = $this->wire(new SessionCSRF());
return $this->CSRF;
}
/**
* Get or set current session handler instance (WireSessionHandler)
*
* #pw-internal
*
* @param WireSessionHandler|null $sessionHandler Specify only when setting, omit to get session handler.
* @return null|WireSessionHandler Returns WireSessionHandler instance, or…
* returns null when session handler is not yet known or is PHP (file system)
* @since 3.0.166
*
*/
public function sessionHandler(WireSessionHandler $sessionHandler = null) {
if($sessionHandler) $this->sessionHandler = $sessionHandler;
return $this->sessionHandler;
}
}