php PHPSESSID 是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1370951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 02:14:01  来源:igfitidea点击:

What is PHPSESSID?

phpcookies

提问by

I'm playing around with cookies. And I dont have any cookies called PHPSESSID.

我在玩饼干。而且我没有任何名为 PHPSESSID 的 cookie。

Do i need it? Can i remove it?

我需要吗?我可以删除它吗?

Whats the "function" of it?

它的“功能”是什么?

if (count($_POST)) {

setcookie("TestCookie", htmlspecialchars($_POST['val']), time()+3600);
}

print_r($_COOKIE);

Prints:

印刷:

Array
(
    [TestCookie] => blabla
    [PHPSESSID] => el4ukv0kqbvtheitroadg7nkp4dncpk3
)

采纳答案by DigitalRoss

PHP uses one of two methods to keep track of sessions. If cookies are enabled, like in your case, it uses them.

PHP 使用两种方法之一来跟踪会话。如果启用了 cookie,就像你的情况一样,它会使用它们。

If cookies are disabled, it uses the URL. Although this canbe done securely, it's harder and it often, well, isn't.See, e.g., session fixation.

如果 cookie 被禁用,它会使用 URL。虽然这可以安全地完成,但它更难,而且通常不是。参见,例如,会话固定

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.

搜索它,你会得到很多 SEO 建议。传统观点是您应该使用 cookie,但 php 会以任何一种方式跟踪会话。

回答by Brad Kent

PHPSESSIDreveals you are using PHP. If you don't want this you can easily change the name using the session.namein your php.inifile or using the session_name()function.

PHPSESSID显示您正在使用PHP。如果你不希望这样,您可以使用轻松地更改名称session.name在您的php.ini文件或使用该session_name()功能。

回答by Noon Silk

It's the identifier for your current session in PHP. If you delete it, you won't be able to access/make use of session variables. I'd suggest you keep it.

它是您在 PHP 中当前会话的标识符。如果删除它,您将无法访问/使用会话变量。我建议你保留它。

回答by Roman Losev

Check php.ini for auto session id.

检查 php.ini 以获取自动会话 ID。

If you enable it, you will have PHPSESSID in your cookies.

如果您启用它,您的 cookie 中将有 PHPSESSID。

回答by Niranjan Bhosale

PHPSESSID is an auto generated session cookie by the server which contains a random long number which is given out by the server itself

PHPSESSID 是服务器自动生成的会话 cookie,其中包含服务器本身给出的随机长数字