BUGFIX: alternative function for versions of PHP prior to version 5.2 (from r96681)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102333 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-12 01:43:32 +00:00
parent c29cf7d302
commit 5c6f3d59d7

View File

@ -22,6 +22,10 @@ class Cookie extends Object {
if(!headers_sent($file, $line)) { if(!headers_sent($file, $line)) {
$expiry = $expiryDays > 0 ? time()+(86400*$expiryDays) : 0; $expiry = $expiryDays > 0 ? time()+(86400*$expiryDays) : 0;
$path = ($path) ? $path : Director::baseURL(); $path = ($path) ? $path : Director::baseURL();
// 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); setcookie($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
} else { } 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); 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);