sachin hunur
sachin hunur

Reputation: 281

PHP cookie name does not accept space values

<?php
include 'lastfive.php';
cal('2016 Trek 8.4 DS');
$product7="2016 Trek 8.4 DS";

if(!isset($_COOKIE[$product7])) {
$value=1;
  echo "Cookie named '" . $product7 . "' is not set!";
setcookie($product7, $value, time() + (86400 * 30), "/");
} 


 else {
  echo "Cookie '" . $product7 . "' is set!<br>";
  echo "Value is: " . $_COOKIE[$product7];
$value=$_COOKIE[$product7]+1;
setcookie($product7, $value, time() + (86400 * 30), "/");
}
?>

This code does not set a cookie. when i remove the space and the '.' the cookie is set. Is there something i am missing?

Upvotes: 0

Views: 478

Answers (1)

Al Amin Chayan
Al Amin Chayan

Reputation: 2500

cookie name is a kind of variable name. So it will not support any character which is not allowed for variable name.

Upvotes: 4

Related Questions