private function performTokenInitialization()
    {
        if (!empty($_COOKIE[$this->sessionCookieName])) {
            $this->sessionToken = $_COOKIE[$this->sessionCookieName];

            if (preg_match('#[a-f0-9]{40}#', $this->sessionToken)) {
                return;
            }
        }

        $this->sessionToken = sha1(uniqid('slabphp', true));

        if (headers_sent()) {
            if ($this->log) {
                $this->log->critical('Failed to save session cookie, headers already sent.');
            }
            return;
        }

        if (!setcookie(
            $this->sessionCookieName,
            $this->sessionToken,
            !empty($this->sessionExpiration) ? (time() + $this->sessionExpiration) : 0,
            $this->sessionCookiePath,
            $this->sessionCookieDomain,
            $this->sessionCookieSecure
        )) {
            if ($this->log) {
                $this->log->critical('Failed to save session cookie!');
            }
        }
    }