mercredi 8 février 2017

Unable to access cookie set on same page after if statement

Vote count: 0

I set a cookie inside php tag on top of the page:

   $cookie_name = "true";
   $cookie_value = "bla";
   setcookie($cookie_name, $cookie_value, "/");
   echo $cookie_name;   // first

   if(isset($_COOKIE["true"]))
   echo $cookie_name;   // second

First echo seems to work fine but I can't echo the second one. It seems as if the if statement is not equaling to true. Can somebody clarify what is going on? I am new to cookies and trying this on localhost with url api.app.localhost.

asked 26 secs ago

Let's block ads! (Why?)



Unable to access cookie set on same page after if statement

Aucun commentaire:

Enregistrer un commentaire