問(wèn)題描述
我在玩餅干.而且我沒(méi)有任何名為 PHPSESSID 的 cookie.
I'm playing around with cookies. And I dont have any cookies called PHPSESSID.
我需要嗎?我可以刪除它嗎?
Do i need it? Can i remove it?
它的功能"是什么?
if (count($_POST)) {
setcookie("TestCookie", htmlspecialchars($_POST['val']), time()+3600);
}
print_r($_COOKIE);
打印:
Array
(
[TestCookie] => blabla
[PHPSESSID] => el4ukv0kqbvoirg7nkp4dncpk3
)
推薦答案
PHP 使用兩種方法之一來(lái)跟蹤會(huì)話.如果啟用了 cookie,就像您的情況一樣,它就會(huì)使用它們.
PHP uses one of two methods to keep track of sessions. If cookies are enabled, like in your case, it uses them.
如果 cookie 被禁用,它會(huì)使用 URL.雖然這可以安全地完成,但它更難,而且通常不是.參見(jiàn),例如,會(huì)話固定.
If cookies are disabled, it uses the URL. Although this can be done securely, it's harder and it often, well, isn't. See, e.g., session fixation.
搜索它,您會(huì)得到很多 SEO 建議.傳統(tǒng)觀點(diǎn)是您應(yīng)該使用 cookie,但 php 會(huì)以任何一種方式跟蹤會(huì)話.
Search for it, you will get lots of SEO advice. The conventional wisdom is that you should use the cookies, but php will keep track of the session either way.
這篇關(guān)于PHPSESSID 是什么?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!