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 :'( Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.