What is PHPSESSID?

PhpCookies

Php Problem Overview


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

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] => el4ukv0kqbvoirg7nkp4dncpk3
)

Php Solutions


Solution 1 - Php

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

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.

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.

Solution 2 - Php

PHPSESSID reveals you are using PHP. If you don't want this you can easily change the name using the session.name in your php.ini file or using the session_name() function.

Solution 3 - Php

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.

Solution 4 - Php

Check php.ini for auto session id.

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

Solution 5 - Php

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTomek WojtekView Question on Stackoverflow
Solution 1 - PhpDigitalRossView Answer on Stackoverflow
Solution 2 - PhpBrad KentView Answer on Stackoverflow
Solution 3 - PhpNoon SilkView Answer on Stackoverflow
Solution 4 - PhpRoman LosevView Answer on Stackoverflow
Solution 5 - PhpNiranjan BhosaleView Answer on Stackoverflow