...

View Full Version : Working with 2 cookies



neobolt
03-13-2009, 05:35 PM
I have a site that allows people to create custom homepages.
They can choose a theme and setup custom links. All of this info is saved to a cookie.

So I guess what I want is to have a "defaultcookie" set when the user accesses the main page. Then when they set there own preferences the "defaultcookie" will be deleted, and the "usercookie" will be set.

Now if they go back to the main page I need some sort of script to check to see if "usercookie" has been set. If it has, then do nothing. If it hasn't been set, then set "defaultcookie".
Is this possible?

kokjj87
03-13-2009, 05:53 PM
//if usercookie is not set
if(!isset($_COOKIE['usercookie']))
{
//set the default cookie
setcookie('defaultcookie', 'your value here', time()+3600);//this will expire in 1hr
}

http://php.net/setcookie

neobolt
03-13-2009, 05:57 PM
Hey, thanks for the quick response. Awesome, I'll give it a shot.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum