AppserverIo\Appserver\ServletEngine\Http\Session::init PHP Method

init() public method

Initializes the session with the passed data.
public init ( mixed $id, string $name, integer | DateTime $lifetime, integer | null $maximumAge, string | null $domain, string $path, boolean $secure, boolean $httpOnly, integer | null $lastActivityTimestamp = null ) : void
$id mixed The session ID
$name string The session name
$lifetime integer | DateTime Date and time after the session expires
$maximumAge integer | null Number of seconds until the session expires
$domain string | null The host to which the user agent will send this cookie
$path string The path describing the scope of this cookie
$secure boolean If this cookie should only be sent through a "secure" channel by the user agent
$httpOnly boolean If this cookie should only be used through the HTTP protocol
$lastActivityTimestamp integer | null The timestamp when the session has been touched the last time
return void
    public function init($id, $name, $lifetime, $maximumAge, $domain, $path, $secure, $httpOnly, $lastActivityTimestamp = null)
    {
        // initialize the session
        $this->id = $id;
        $this->name = $name;
        $this->lifetime = $lifetime;
        $this->maximumAge = $maximumAge;
        $this->domain = $domain;
        $this->path = $path;
        $this->secure = $secure;
        $this->httpOnly = $httpOnly;
        // the UNIX timestamp where the last action on this session happens
        if ($lastActivityTimestamp == null) {
            $this->lastActivityTimestamp = time();
        } else {
            $this->lastActivityTimestamp = $lastActivityTimestamp;
        }
    }