src/Session/SessionMiddleware.php
private function attachSessionCookie(ResponseInterface $response, int $time): ResponseInterface
    {
        // Get the session id, name and the cookie options.
        $id = session_id();
        $name = session_name();
        $options = session_get_cookie_params();

        // Create a cookie header.
        $header = urlencode($name) . '=' . urlencode($id);

        if ($options['lifetime'] > 0) {

            $expires = gmdate(self::DATE_FORMAT, $time + $options['lifetime']);

            $header .= "; expires={$expires}; max-age={$options['lifetime']}";

        }

        if ($options['path']) $header .= "; path={$options['path']}";
        if ($options['domain']) $header .= "; domain={$options['domain']}";
        if ($options['secure']) $header .= '; secure';
        if ($options['httponly']) $header .= '; httponly';

        // Return a new response with the cookie header.
        return $response->withAddedHeader('set-cookie', $header);
    }
private function attachSessionCookie(ResponseInterface $response, int $time): ResponseInterface
    {
        // Get the session id, name and the cookie options.
        $id = session_id();
        $name = session_name();
        $options = session_get_cookie_params();

        // Create a cookie header.
        $header = urlencode($name) . '=' . urlencode($id);

        if ($options['lifetime'] > 0) {

            $expires = gmdate(self::DATE_FORMAT, $time + $options['lifetime']);

            $header .= "; expires={$expires}; max-age={$options['lifetime']}";

        }

        if ($options['path']) $header .= "; path={$options['path']}";
        if ($options['domain']) $header .= "; domain={$options['domain']}";
        if ($options['secure']) $header .= '; secure';
        if ($options['httponly']) $header .= '; httponly';

        // Return a new response with the cookie header.
        return $response->withAddedHeader('set-cookie', $header);
    }
private function attachSessionCookie ( ResponseInterface $ response , int $ time ) : ResponseInterface { // Get the session id, name and the cookie options. $ id = session_id ( ) ; $ name = session_name ( ) ; $ options = session_get_cookie_params ( ) ; // Create a cookie header. $ header = urlencode ( $ name ) . '=' . urlencode ( $ id ) ; if ( $ options [ 'lifetime' ] > 0 ) { $ expires = gmdate ( self :: DATE_FORMAT , $ time + $ options [ 'lifetime' ] ) ; $ header .= "; expires={$expires}; max-age={$options['lifetime']}" ; } if ( $ options [ 'path' ] ) $ header .= "; path={$options['path']}" ; if ( $ options [ 'domain' ] ) $ header .= "; domain={$options['domain']}" ; if ( $ options [ 'secure' ] ) $ header .= '; secure' ; if ( $ options [ 'httponly' ] ) $ header .= '; httponly' ; // Return a new response with the cookie header. return $ response -> withAddedHeader ( 'set-cookie' , $ header ) ; }
Attach a session cookie to the given response.

@param \Psr\Http\Message\ResponseInterface   $response
@param int                                   $time
@return \Psr\Http\Message\ResponseInterface

@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1402-L1476
Attach a session cookie to the given response .