src/StartSessionMiddleware.php
private function withSessionCookie(ResponseInterface $response, string $session_id): ResponseInterface
    {
        // Merge session cookie options.
        $default = session_get_cookie_params();

        $default = array_change_key_case($default, CASE_LOWER);
        $options = array_change_key_case($this->options, CASE_LOWER);

        $options = array_merge($default, $options);

        if ($options['lifetime'] < 0) $options['lifetime'] = 0;

        // Create a session cookie and attach it to the response.
        $cookie = SetCookie::create($this->name, $session_id)
            ->withMaxAge($options['lifetime'])
            ->withPath($options['path'])
            ->withDomain($options['domain'])
            ->withSecure($options['secure'])
            ->withHttpOnly($options['httponly']);

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

            $cookie = $cookie->withExpires(time() + $options['lifetime']);

        }

        return FigResponseCookies::set($response, $cookie);
    }
private function withSessionCookie(ResponseInterface $response, string $session_id): ResponseInterface
    {
        // Merge session cookie options.
        $default = session_get_cookie_params();

        $default = array_change_key_case($default, CASE_LOWER);
        $options = array_change_key_case($this->options, CASE_LOWER);

        $options = array_merge($default, $options);

        if ($options['lifetime'] < 0) $options['lifetime'] = 0;

        // Create a session cookie and attach it to the response.
        $cookie = SetCookie::create($this->name, $session_id)
            ->withMaxAge($options['lifetime'])
            ->withPath($options['path'])
            ->withDomain($options['domain'])
            ->withSecure($options['secure'])
            ->withHttpOnly($options['httponly']);

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

            $cookie = $cookie->withExpires(time() + $options['lifetime']);

        }

        return FigResponseCookies::set($response, $cookie);
    }
private function withSessionCookie ( ResponseInterface $ response , string $ session_id ) : ResponseInterface { // Merge session cookie options. $ default = session_get_cookie_params ( ) ; $ default = array_change_key_case ( $ default , CASE_LOWER ) ; $ options = array_change_key_case ( $ this -> options , CASE_LOWER ) ; $ options = array_merge ( $ default , $ options ) ; if ( $ options [ 'lifetime' ] < 0 ) $ options [ 'lifetime' ] = 0 ; // Create a session cookie and attach it to the response. $ cookie = SetCookie :: create ( $ this -> name , $ session_id ) -> withMaxAge ( $ options [ 'lifetime' ] ) -> withPath ( $ options [ 'path' ] ) -> withDomain ( $ options [ 'domain' ] ) -> withSecure ( $ options [ 'secure' ] ) -> withHttpOnly ( $ options [ 'httponly' ] ) ; if ( $ options [ 'lifetime' ] > 0 ) { $ cookie = $ cookie -> withExpires ( time ( ) + $ options [ 'lifetime' ] ) ; } return FigResponseCookies :: set ( $ response , $ cookie ) ; }
Attach a session cookie with the given sesison id to the given response.

@param \Psr\Http\Message\ResponseInterface   $response
@param string                                $session_id
@return \Psr\Http\Message\ResponseInterface
Attach a session cookie with the given sesison id to the given response .