luke777 Posted February 25, 2010 Share Posted February 25, 2010 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 More sharing options...
otuatail Posted February 25, 2010 Share Posted February 25, 2010 You can't read the cookie strait away. If you go back and look again it will be there. This had me going for a bit. Desmond. Link to comment https://forums.phpfreaks.com/topic/193349-cookie-challenge/#findComment-1018037 Share on other sites More sharing options...
luke777 Posted February 25, 2010 Author Share Posted February 25, 2010 so you gotta do 2 pageviews before i can update the user with how many days left? thats rediculous... there must b a way! Link to comment https://forums.phpfreaks.com/topic/193349-cookie-challenge/#findComment-1018056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.