protected function makeCookie(Request $request)
{
// merge native PHP session cookie params with custom ones.
$params = array_replace(session_get_cookie_params(), $this->cookies);
// if the cookie lifetime is not 0 (closes when browser window closes),
// add the request time and the lifetime to get the expiration time of
// the cookie.
if ($params['lifetime'] !== 0) {
$params['lifetime'] = $request->server->get('REQUEST_TIME') + $params['lifetime'];
}
return new Cookie($this->session->getName(), $this->session->getId(), $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
}