From 3f10eeaa88152ebae3c6a177e076c501cdc50c0a Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 14 Mar 2017 22:25:20 +0100 Subject: [PATCH] Cookies: Set expires flag for remember cookies Without this, session remembering would not work in Internet Explorer (and Edge?). Fixes #1127. --- framework/core/src/Http/CookieFactory.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Http/CookieFactory.php b/framework/core/src/Http/CookieFactory.php index 49899c6bf..868db278c 100644 --- a/framework/core/src/Http/CookieFactory.php +++ b/framework/core/src/Http/CookieFactory.php @@ -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);