Web Hosting Talk







View Full Version : [Cookies]


JustinSmall
03-02-2008, 07:06 PM
Ok I want to create a cookie for 12 hours called "viewed"

and I want it to go like this

if isset { do nothing } else { set cookie & more code } help please!

Dan L
03-02-2008, 08:18 PM
<?php
if($_COOKIE['viewed'] != 'yes') {
// code
} else {
setcookie('viewed','yes',time() + (60 * 60 * 12));
// code
}
?>

Codelphious
03-03-2008, 01:41 AM
This should do it.


<?php

if(!isset($_COOKIE['viewed'])) {
setcookie("viewed", "true", time() + (60*60*12));
// Do other stuff

}
?>

loty
03-13-2008, 03:37 AM
This should do it.


<?php

if(!isset($_COOKIE['viewed'])) {
setcookie("viewed", "true", time() + (60*60*12));
// Do other stuff

}
?>


just for the record,
(60*60*12), it's egal to 60 seconds * 60 minutes* 12 hours