Jump to content

PHP Cookie Issue, URL Address As Name Not Working?


DrRobot

Recommended Posts

Hello,

 

I'm having an issue with using a php variable (of the current page url) as a cookies name. Here's an example of what I'm trying to do:

 

$directory = "/main/index.php?id=7";
$cName = "path_".$directory;
if(isset($_COOKIE[$cName])){
   echo "Do something NOW!!!";
   setcookie($cName, '1', mktime(23,59,59));
}

 

echoing the isset check doesn't return anything, no 0, no 1.

 

I can print_r $_COOKIE; and it shows the cookie exists, I just can't check if it exists with what I'm doing here.

 

From what I've learned is that the cookie name is something like: "testing" it works just fine, but if it's that $cName variable it doesn't work.

 

Any ideas?

If you were developing with error reporting enabled, which you should be, you'd see a warning similar to: Warning: Cookie names can not contain any of the following '=,; \t\r\n\013\014' . . .

If you were developing with error reporting enabled, which you should be, you'd see a warning similar to: Warning: Cookie names can not contain any of the following '=,; \t\r\n\013\014' . . .

I guess this is probably the reason that the $_COOKIE[$cName] isn't working.

 

Also, I have error_reporting(E_ALL); at the top of my file, I guess it's not working? BTW, I'm using WAMP.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.