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
This commit is contained in:
Andrew O'Neil 2008-11-19 00:57:28 +00:00 committed by Sam Minnee
parent e3298047c3
commit 4c81b8c3a5

View File

@ -13,10 +13,11 @@ class Cookie extends Object {
*/ */
static function set($name, $value, $expiryDays = 90) { static function set($name, $value, $expiryDays = 90) {
if(!headers_sent($file, $line)) { 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; $_COOKIE[$name] = $value;
} else { } 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);
} }
} }