Jump to content

[SOLVED] Can I set a cookie name with a variable?


blurredvision

Recommended Posts

I have a cookie that I'm setting like such:

 

setcookie("cookiename", $value, time()+3600*24*5);

 

That works perfectly fine.  However, I'm now wanting to create my cookie in a different way, by using a variable to set the name of the cookie.  Here's what I'd like to do:

 

setcookie($cookie1, $value, time()+3600*24*5);

 

I cannot get that work.  Can you not use a variable to set the cookie name, or is my syntax wrong?

Figured out what I was doing wrong.  I was completely forgetting to pass the $value into the function.  What a stupid oversight. :)  I was so stuck on trying to find through google if it was correct syntax or not that I didn't look at other factors.

 

Thanks flyhoney, sorry to waste your time.

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.