Jump to content

cookie challenge!


luke777

Recommended Posts

right basically... what i want to do is give a user a cookie (the date 1 - 30) and at the top right of the page will say "SALE NOW ON - 6 DAYS LEFT" then the next day the formula is $date - $cookie = $timeleft

 

ie. they come back one day later and theres "...5 DAYS LEFT"

 

heres what iv tried....

 

 

<?php
$date = date("d");
$cookie = $_COOKIE["user"];

if ($cookie!="") {
$new = $date - $cookie;
$expire=time()+60*60*24*6;
setcookie("user", "$date", $expire);
}
else
{
$new = "22";
}


echo $cookie."<br>";

echo "cookie: ".$cookie;
echo "<br>sent: $new";
?>

 

 

this is me just trying to sort the cookie out, is there any easy way of doing this? i thought it would be pretty smart to make each customer think theres an expiring sale on :) BUT i suck at php... and even the above isnt doin what i thought it would  :'(

Link to comment
https://forums.phpfreaks.com/topic/193349-cookie-challenge/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.