View Full Version : Get and Set Cookies

04-04-2003, 08:49 PM
Can someone answer this or point me to a source of info? How do you save a cookie to the user's computer and how do you read that cookie when they open the web site?

04-04-2003, 08:55 PM
Try a basic search...


04-04-2003, 10:06 PM
// This goes before the <html> tag

setcookie('cookiename','cookie info',time()+3600);

// time() + 3600 is the expiration. time()+3600 would be 1 hour ( 3600 seconds )

That would set a cookie to the users computer, that would last the set time. To display the contents of the cookie, you need to use $HTTP_COOKIE_VARS ( or $_COOKIE )

// an example, set a cookie then get its value


// sets a cookie called name, with a value of matt that lasts 5 minutes.

echo $_COOKIE['name'];

// would write matt on to the page.

04-05-2003, 12:04 PM
Thanks a lot for the answers.

04-05-2003, 12:10 PM
no prob :thumbsup:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum