PHP Class SimpleSAML_SessionHandlerCookie, simplesamlphp

This file defines a base class for session handlers that need to store the session id in a cookie. It takes care of storing and retrieving the session id.
Author: Olav Morken, UNINETT AS. ([email protected])
Inheritance: extends SimpleSAML_SessionHandler
Datei anzeigen Open project: simplesamlphp/simplesamlphp Class Usage Examples

Protected Properties

Property Type Description
$cookie_name string This variable contains the session cookie name.

Public Methods

Method Description
getCookieSessionId ( ) : string | null Retrieve the session ID saved in the session cookie, if there's one.
getSessionCookieName ( ) : string Retrieve the session cookie name.
hasSessionCookie ( ) : boolean Check whether the session cookie is set.
newSessionId ( ) : string Create a new session id.
setCookie ( string $sessionName, string | null $sessionID, array $cookieParams = null ) Set a session cookie.

Protected Methods

Method Description
__construct ( ) This constructor initializes the session id based on what we receive in a cookie. We create a new session id and set a cookie with this id if we don't have a session id.

Private Methods

Method Description
createSessionID ( ) : string This static function creates a session id. A session id consists of 32 random hexadecimal characters.
isValidSessionID ( string $session_id ) : boolean This static function validates a session id. A session id is valid if it only consists of characters which are allowed in a session id and it is the correct length.

Method Details

__construct() protected method

This constructor initializes the session id based on what we receive in a cookie. We create a new session id and set a cookie with this id if we don't have a session id.
protected __construct ( )

getCookieSessionId() public method

Retrieve the session ID saved in the session cookie, if there's one.
public getCookieSessionId ( ) : string | null
return string | null The session id saved in the cookie or null if no session cookie was set.

getSessionCookieName() public method

Retrieve the session cookie name.
public getSessionCookieName ( ) : string
return string The session cookie name.

hasSessionCookie() public method

This function will only return false if is is certain that the cookie isn't set.
public hasSessionCookie ( ) : boolean
return boolean True if it was set, false otherwise.

newSessionId() public method

Create a new session id.
public newSessionId ( ) : string
return string The new session id.

setCookie() public method

Set a session cookie.
public setCookie ( string $sessionName, string | null $sessionID, array $cookieParams = null )
$sessionName string The name of the session.
$sessionID string | null The session ID to use. Set to null to delete the cookie.
$cookieParams array Additional parameters to use for the session cookie.

Property Details