Cookies: Set expires flag for remember cookies

Without this, session remembering would not work in Internet
Explorer (and Edge?).

Fixes #1127.
This commit is contained in:
Franz Liedke 2017-03-14 22:25:20 +01:00
parent 231d018de5
commit 2f714a01ed
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -45,8 +45,17 @@ class CookieFactory
// Parse the forum's base URL so that we can determine the optimal cookie settings
$url = parse_url(rtrim($this->app->url(), '/'));
return SetCookie::create($name, $value)
->withMaxAge($maxAge)
$cookie = SetCookie::create($name, $value);
// Make sure we send both the MaxAge and Expires parameters (the former
// is not supported by all browser versions)
if ($maxAge) {
$cookie = $cookie
->withMaxAge($maxAge)
->withExpires(time() + $maxAge);
}
return $cookie
->withPath(array_get($url, 'path') ?: '/')
->withSecure(array_get($url, 'scheme') === 'https')
->withHttpOnly(true);