27 private $session_id = null;
45 parent::__construct();
48 $this->cookie_name =
$config->getString(
'session.cookie.name',
'SimpleSAMLSessionID');
59 $this->session_id = self::createSessionID();
62 return $this->session_id;
73 if ($this->session_id === null) {
74 if (self::hasSessionCookie()) {
76 $this->session_id =
$_COOKIE[$this->cookie_name];
80 if (!self::isValidSessionID($this->session_id)) {
86 return $this->session_id;
97 return $this->cookie_name;
108 return bin2hex(openssl_random_pseudo_bytes(16));
122 if (!is_string($session_id)) {
126 if (strlen($session_id) != 32) {
130 if (preg_match(
'/[^0-9a-f]/', $session_id)) {
147 return array_key_exists($this->cookie_name,
$_COOKIE);
162 assert(is_string($sessionName));
165 if ($cookieParams !== null) {
166 $params = array_merge($this->getCookieParams(), $cookieParams);
168 $params = $this->getCookieParams();
static isValidSessionID($session_id)
This static function validates a session id.
getCookieSessionId()
Retrieve the session ID saved in the session cookie, if there's one.
__construct()
This constructor initializes the session id based on what we receive in a cookie. ...
static createSessionID()
This static function creates a session id.
getSessionCookieName()
Retrieve the session cookie name.
hasSessionCookie()
Check whether the session cookie is set.
static createSession($sessionId)
Create a new session and cache it.
newSessionId()
Create a new session id.
Attribute-related utility methods.
setCookie($sessionName, $sessionID, array $cookieParams=null)
Set a session cookie.
static getInstance($instancename='simplesaml')
Get a configuration file by its instance name.