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
This commit is contained in:
Geoff Munn 2010-01-12 03:07:07 +00:00 committed by Sam Minnee
parent 8d7658109e
commit 6883c8e3c6

View File

@ -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);
}