3
的IETF推薦使用base64編碼二進制cookie值: http://tools.ietf.org/html/draft-ietf-httpstate-cookie-07如何獲得PHP「setrawcookie」值?
於是我就用setrawcookie(..)
,但我不知道該用什麼變量獲得餅乾回來,因爲$_COOKIE[..]
仍然使用匹配setcookie(..)
的URL解碼。這會在輸出中用「」替換「+」。
<?php
var_dump($_COOKIE['TEST']);
$binary_string = "";
for($index = 0; $index < 256; $index++){
$binary_string .= chr($index);
}
$encoded_data = base64_encode($binary_string);
var_dump($encoded_data);
$cookie_set = setrawcookie('TEST', $encoded_data, time() + 3600);
?>
你確定你的cookie設置正確嗎?你正在使用'var_dump'來輸出一些數據,並且在這個cookie不能被設置之後,你可能會使用一些舊的cookie? – 2010-04-22 20:41:01
只需重新加載頁面 – user250343 2010-04-23 00:09:21