NestedCodeblocksFTW
NestedCodeblocksFTW

Reputation: 746

php cookies and browser not sending cookie to server

So I have a problem where this doesn't work.. the cookie file named "Main" exists in browser cache, but when I try the below code nothing is collected from it.

 if (isset($_COOKIE["Main"])){
 $user_cookie = $_COOKIE["Main"];
 }

Further digging shows I have another cookie for the same domain name that is part of a wikibridge...

both cookies have the same contents.. a username "John" exactly.

when I try

var_dump($_COOKIE); exit;

I get a bunch of array data, collected from the cookies my browser sends back, but it seems my browser firefox is not sending the "Main" cookie backm, its only sending a bunch of other cookies all part of the same domain name.

So despite this $_COOKIE["Main"] existing, it never gets sent back to the server for php to get it contents.

HELP

Upvotes: 0

Views: 2373

Answers (1)

Mike Brant
Mike Brant

Reputation: 71384

There are a few possible reasons for cookies of same domain not being sent.

First, I would check to see if the cookie is set as a secure cookie which is only sent for https requests.

Second, I would check if the cookie has a specific path that it is set to be active for and your request is not part of that path.

Upvotes: 4

Related Questions