From 6883c8e3c613524da6a5c34b6d871d61bc508678 Mon Sep 17 00:00:00 2001 From: Geoff Munn Date: Tue, 12 Jan 2010 03:07:07 +0000 Subject: [PATCH] BUGFIX: alternative function for versions of PHP prior to version 5.2 git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96681 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/Cookie.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Cookie.php b/core/Cookie.php index cb82826bd..bd62ebf90 100755 --- a/core/Cookie.php +++ b/core/Cookie.php @@ -22,7 +22,11 @@ class Cookie extends Object { if(!headers_sent($file, $line)) { $expiry = $expiryDays > 0 ? time()+(86400*$expiryDays) : 0; $path = ($path) ? $path : Director::baseURL(); - setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly); + // Versions of PHP prior to 5.2 do not support the $httpOnly value + if(version_compare(phpversion(), 5.2, '<')) + setcookie($name, $value, $expiry, $path, $domain, $secure); + else + setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly); } else { if(self::$report_errors) user_error("Cookie '$name' can't be set. The site started outputting was content at line $line in $file", E_USER_WARNING); }