2010-09-01 37 views

回答

4

這是正確的!

$_COOKIE

的$ _COOKIE值由 在 用戶代理的請求而接收的cookie的內容來確定。

1

上點差不多...

你基本上使用$_COOKIE從瀏覽器獲取存儲在cookie中數據

當然餅乾並不總是十分可靠,因爲他們可以關閉由客戶端,但仍然廣泛使用。

2

的$ _COOKIE超全局變量的內容:

使用通過HTTP的Cookie傳遞給當前腳本變量superglobal$_COOKIE關聯array檢索cookies with PHP當返回。

要檢查所有的Cookie變量簡單地使用:

print_r($_COOKIE); 

檢索特定cookie變量的值,引用cookie變量的關鍵:

echo $_COOKIE["myVariableName"]; 

有關檢索最棘手的事情使用PHP的cookie是一個cookie變量在設置之後的請求之前不可用。所以你不能使用PHP訪問cookie,直到下一頁加載後

// Cannot have output before setting cookies. 
// Cookie will be sent along w the rest of the HTTP headers. 
setcookie("name", "Pat"); 

// If the above was the first time "name" was set, 
// this will echo NOTHING!!! 
echo $_COOKIE["name"]; 

// You will only be able to retrieve $_COOKIE["name"] after the 
// next page load. 
相關問題