ParoX
ParoX

Reputation: 5931

$_COOKIE[] will not accept string with periods?

<?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.

Upvotes: 1

Views: 133

Answers (1)

ircmaxell
ircmaxell

Reputation: 165271

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..

Upvotes: 3

Related Questions