
-----------------------------------
Amailer
Thu Mar 04, 2004 7:19 pm

COOKIE [ SOLVED ]
-----------------------------------
Okay, suppose i have this.

a variable
$variable = 'text.'$id_from_db;

i set a cookie for the $variable
setcookie($variable, $count, time()+60*60*24);


now what i want to do is..... to check if the cookie is set or not i.e
$COOKIE[$variable];

that doens't seem to work though, how would i get a cookie by using a variabel ( i.e $COOKIE[$variable]; ) if you know what i mean...

-----------------------------------
wtd
Thu Mar 04, 2004 8:19 pm


-----------------------------------
Try using $_COOKIE instead of $COOKIE.

-----------------------------------
Amailer
Thu Mar 04, 2004 8:26 pm


-----------------------------------
wouldn't that be just as a normal variable? also how does this solve my problem :S maby iv not explained it well enough.

I have set a cookie:


$cookie_name = 'gfxpro.'.$d2['d2_id'];

....
$count = 1;
setcookie($cookie_name, $count, time()+60*60*24);


now i want to check if that cookie isset so i did this:

if( isset($_COOKIE[$cookie_name]) ) {
...
}


but that doesn't work is there another way around this?

-----------------------------------
wtd
Thu Mar 04, 2004 8:31 pm


-----------------------------------
RTFM  :-)

http://ca.php.net/manual/en/features.cookies.php

-----------------------------------
Amailer
Thu Mar 04, 2004 8:43 pm


-----------------------------------
ya but hmm but it's not working... i don't think it's setting cookie right with the name...

-----------------------------------
wtd
Thu Mar 04, 2004 9:09 pm


-----------------------------------
It should be noted that changes in cookies won't be noticeable until the page is reloaded.

-----------------------------------
Amailer
Thu Mar 04, 2004 9:10 pm


-----------------------------------
actually i checked, it is setting the cookie but  the 
if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {

doesn't seem to be working, why!


problem solved:
i think it had to do with the . in the name... hmm idk i removed it and it worked lol...
