4
我發現很難得到由evercookie設置的cookie的價值。Evercookie使用問題
我想要做的只是檢查是否設置了名稱evercookie或未設置。如果它沒有設置,那麼我想將它設置爲一個數字。
類似如下: var cookie_value = get_cookie_value; if(cookie_value == notdefined) set coookie to「12345」 else 想在php代碼中使用它。
Eveercoohie使用代碼如下從http://samy.pl/evercookie/
var ec = new evercookie();
// set a cookie "id" to "12345"
// usage: ec.set(key, value)
ec.set("id", "12345");
// retrieve a cookie called "id" (simply)
ec.get("id", function(value) { alert("Cookie value is " + value) });
// or use a more advanced callback function for getting our cookie
// the cookie value is the first param
// an object containing the different storage methods
// and returned cookie values is the second parameter
function getCookie(best_candidate, all_candidates)
{
alert("The retrieved cookie is: " + best_candidate + "\n" +
"You can see what each storage mechanism returned " +
"by looping through the all_candidates object.");
for (var item in all_candidates)
document.write("Storage mechanism " + item +
" returned " + all_candidates[item] + " votes<br>");
}
ec.get("id", getCookie);
// we look for "candidates" based off the number of "cookies" that
// come back matching since it's possible for mismatching cookies.
// the best candidate is very-very-likely the correct one
只有'$ _COOKIE',而不是'$ _COOKIES',當然是 –
「在下一次刷新時,evercookie代碼應該檢測到它的一個元素包含一個值,並將所有其他元素設置爲相同的值「。這是與.set()函數? .set()調用客戶端JavaScript中所需的全部內容嗎?如果是這樣,那麼在什麼情況下,客戶端會使用.get()? – Doug