PHPSESSID 是什么?
我在玩饼干.而且我没有任何名为 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 使用两种方法之一来跟踪会话.如果启用了 cookie,就像您的情况一样,它就会使用它们.
PHP uses one of two methods to keep track of sessions. If cookies are enabled, like in your case, it uses them.
如果 cookie 被禁用,它会使用 URL.虽然这可以安全地完成,但它更难,而且通常不是.参见,例如,会话固定.
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.
搜索它,您会得到很多 SEO 建议.传统观点是您应该使用 cookie,但 php 会以任何一种方式跟踪会话.
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.
相关文章