webCOMAND

session::__construct()

The session constructor creates a new object for managing a session for the current request.

Prototype

session __construct(array $options = [])

Parameters

  • options - Optional associative array of options with the following key/value pairs.
    • gc - Garbage Collection probability.  Valid values are 0-1 where 0 = never remove old sessions and 1 = always clean up old sessions.  Will default to PHP's default, which is typical 0.01 (1%).
    • lifetime or cookie_lifetime - Number of seconds the sessions should be kept before potential removal.  Will default to webCOMAND default of 5 days.
    • path - File system path where sessions will be stored.  Will default to PHP's default session path, which is typically /var/lib/php/session.

Example

$session = new \io_comand_web\session([
    'cookie_lifetime' => 31536000 // 365 days * 24 hrs * 60 min * 60 sec
]);
$session_id = $session->get('id');