Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 COOKIE [ SOLVED ]
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Amailer




PostPosted: Thu Mar 04, 2004 7:19 pm   Post subject: 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...
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Mar 04, 2004 8:19 pm   Post subject: (No subject)

Try using $_COOKIE instead of $COOKIE.
Amailer




PostPosted: Thu Mar 04, 2004 8:26 pm   Post subject: (No subject)

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:

code:

$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:
code:

if( isset($_COOKIE[$cookie_name]) ) {
...
}


but that doesn't work is there another way around this?
wtd




PostPosted: Thu Mar 04, 2004 8:31 pm   Post subject: (No subject)

RTFM Smile

http://ca.php.net/manual/en/features.cookies.php
Amailer




PostPosted: Thu Mar 04, 2004 8:43 pm   Post subject: (No subject)

ya but hmm but it's not working... i don't think it's setting cookie right with the name...
wtd




PostPosted: Thu Mar 04, 2004 9:09 pm   Post subject: (No subject)

It should be noted that changes in cookies won't be noticeable until the page is reloaded.
Amailer




PostPosted: Thu Mar 04, 2004 9:10 pm   Post subject: (No subject)

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...
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: