From 4c81b8c3a539f0a2a0bfe769ba00b71e69be4c2f Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 19 Nov 2008 00:57:28 +0000 Subject: [PATCH] BUGFIX #2714 - Cookie::set doesn't operate correctly with expiryDays 0 (wakeless) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66196 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Cookie.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/Cookie.php b/core/Cookie.php index 554245be9..fba4a11f4 100755 --- a/core/Cookie.php +++ b/core/Cookie.php @@ -13,10 +13,11 @@ class Cookie extends Object { */ static function set($name, $value, $expiryDays = 90) { if(!headers_sent($file, $line)) { - setcookie($name, $value, time()+(86400*$expiryDays), Director::baseURL()); + $expiry = $expiryDays > 0 ? time()+(86400*$expiryDays) : 0; + setcookie($name, $value, $expiry, Director::baseURL()); $_COOKIE[$name] = $value; } else { - // if(Director::isDevMode()) user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING); + if(Director::isDev()) user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING); } }