$ _SERVER ['HTTP_COOKIE'] returns two PHPSESSID

I get two PHPSESSID when printing $_SERVER['HTTP_COOKIE'] . In fact, I do not know how it is installed twice, only on my local system. When I check the cookie SERVER, like:

 echo $_SERVER['HTTP_COOKIE']; //result 'fe_toolbar=false; fe_toolbar=false; PHPSESSID=4tvbovcjk0msf9dvibeb31c2b7; langId=1; backendLangId=2; PHPSESSID=46aagg1hg7as2uh9bihjlpp8h7' 

When I check my cookie one, like:

 print_r($_COOKIE); //result array ( 'fe_toolbar' => 'false', 'PHPSESSID' => '4tvbovcjk0msf9dvibeb31c2b7', ) 
+4
source share
1 answer

You may have multiple cookies with the same name. This happens when you set a cookie with different Path or Domain attributes. They are all sent to the server.

enter image description here

RFC 6265 specific

if the Cookie header contains two cookies with the same name (for example, which were set with different Path or Domain attributes), the servers MUST NOT rely on the order in which these cookies appear in the header.

Your $_COOKIE will be populated with one of these values.

+3
source

Source: https://habr.com/ru/post/1385117/


All Articles