Patch HTTP-host cookies and basepath detection, by Rob

This commit is contained in:
Garvin Hicking
2007-05-16 13:29:28 +00:00
parent 60fcfb95c4
commit 23ae248be3
3 changed files with 9 additions and 8 deletions
+5 -1
View File
@@ -587,12 +587,16 @@ function serendipity_JSsetCookie($name, $value) {
function serendipity_setCookie($name, $value, $securebyprot = true) {
global $serendipity;
$host = $_SERVER['HTTP_HOST'];
if ($securebyprot) {
$secure = (strtolower($_SERVER['HTTPS']) == 'on') ? true : false;
if ($pos = strpos($host, ":")) {
$host = substr($host, 0, $pos);
}
} else {
$secure = false;
}
setcookie("serendipity[$name]", $value, time()+60*60*24*30, $serendipity['serendipityHTTPPath'], $_SERVER['HTTP_HOST'], $secure);
setcookie("serendipity[$name]", $value, time()+60*60*24*30, $serendipity['serendipityHTTPPath'], $host, $secure);
$_COOKIE[$name] = $value;
$serendipity['COOKIE'][$name] = $value;
}