If you are good with the setcookie function, please help me out here. I'm totally frustrated. I just can't get it to work.
I'm adding themes to my site and I want the user to choose a theme. Then the name of the theme will be stored in the user's computer for a long time meaning next time the user loads my site, s/he will see the theme s/he previously chose. and until s/he changes the theme but going here
http://regretless.com/dodo/pure/domain/themes.php
it will stay the same.
but my problem is once i close the browser, the cookie stored seems to be lost as well. i just don't know how to keep it longer.
here's my code:
function setpetheme($css) {
setcookie("petheme", $HTTP_COOKIE_VARS["petheme"], time()-30000000);
setcookie("petheme", $css, time()+30000000);
$HTTP_COOKIE_VARS["petheme"] = $css;
}
/*
function getpetheme() {
$css = $HTTP_COOKIE_VARS["petheme"];
if($css == "") {
$css = "hkgreen";
setcookie("petheme", $css, time()+30000000);
$HTTP_COOKIE_VARS["petheme"] = $css;
}
return $css;
}
*/
if($css)
setpetheme($css);
else
$css = $HTTP_COOKIE_VARS["petheme"];
//print "$css";
if(!$css)
$css = "hkgreen";
i put this in the parent directory of my site.
you can test it out at http://pure-essence.net
please help!!!