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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.