私は Set-Cookie 関数を使用しています..クロムとFirefoxで正常に動作します。
Cookie が設定され、firebug で確認できます。
しかし、何らかの理由でIEでCookieを設定していません
私の構文が正しいかどうか、または何か間違っているかどうかを誰かが確認できますか?
function generateSession($cookieName="wic_secure_sess", $idTag="", $numChars=32, $expireSeconds=0, $path=null, $domain=null, $secure=2) {
if (!isset($_COOKIE[$cookieName])) {
$sessId = $idTag;
for ($i=0; $i<$numChars; $i++) {
srand((double)microtime()*1000000);
$randomType=rand(1, 3);
srand((double)microtime()*1000000);
switch ($randomType) {
case 1:
$sessId.=chr(rand(65, 90));
break;
case 2:
$sessId.=chr(rand(97, 122));
break;
case 3:
$sessId.=rand(0, 9);
break;
}
}
$expires = str_replace('+0000', 'GMT', gmdate('r', strtotime('+30 days')));
if ($expireSeconds != 0) {
$expireSeconds = time()+$expireSeconds;
}
if (livecheck() || stagecheck()) {
header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expires."; path=".$path.";HttpOnly;secure;");
}
else {
header( "Set-Cookie:". $cookieName."=".$sessId."; expires=".$expires."; path=".$path.";HttpOnly");
}
} else {
$sessId = $_COOKIE[$cookieName];
}
return $sessId;
}
?>
I dont want to use setcookie() because i am running php4 version since php4 does not support httponly in the setcookie() function
編集: php setcookie() 関数は IE で完全に正常に動作します。header() を使用すると、問題が発生します。
setcookie($cookieName, $sessId, $expireSeconds, $path, $domain, $secure);
ここに私の関数への呼び出しがあります:
generateSession( "my_sess", "", 20, 14400, "/");