Log in

View Full Version : cookies



lankinator
03-25-2007, 01:25 PM
How do i create a cookie that will hide a section on my page when the cookie is set and show the section when the cookie deleted?

pcbrainbuster
03-25-2007, 01:41 PM
Use ifs and elses...

Titan85
03-25-2007, 01:56 PM
Yeah, just do this:
<?php

if (isset($_COOKIE['cookiename'])) {
// what you want to have if cookie is set
} else {
// what you want to have if cookie is not set
}

?>Hope that explains it ;)

boxxertrumps
03-25-2007, 04:35 PM
Then to set the cookie...

$coo = setcookie("cookiename","value",time()+expire time,"/","domain");
if (!$coo) {echo "Failed";} else {echo "Successful";}

* expires in- 3600*12 = 12 hours, 3600*24*7 = 7 days, 3600*24*365 = 365 days
* Domain - your web address: www.domain.com