views:

22

answers:

1
<?php
  $Test = "dsdsdad.dsad";

  if (isset($_COOKIE["$Test"])) {
      echo "I GOT A COOKIE WITH A PERIOD";
  } else {
    setcookie("$Test", "yes", time()+60*60*24*3);
  }

  $Test = "dsdsdaddsad";

  if (isset($_COOKIE["$Test"])) {
      echo "I GOT A COOKIE WITHOUT A PERIOD";
  } else {
    setcookie("$Test", "yes", time()+60*60*24*3);
  }

?>

It seems that $_COOKIE[] will not accept anything with a period in it. However, the setcookie function sets both cookies fine. What is the way around this? I'd like it to read a cookie with a dot.

+2  A: 

Please see the documentation.

So, if you set the cookie dsdsdad.dsad, it'll be stored as dsdsdad_dsad when PHP parses the cookie headers..

ircmaxell
+1 wow, didn't know that
nikic