I am storing cookies in our visitors browser. If the cookie is older then 7 days they should be redirected to another page. If the cookie is not older then 7 days they will continue going to the page they visited directly from the address bar. Below is an example of my code and where I am stuck at. if(!$cookie['redirect']){ $today = date("m.d.y"); setcookie("redirect",$today, time()+3600*1080); } $cookiedate = $_COOKIE['redirect']; if($cookiedate > ) PHP: As you can see I stored the current (today's date) in the cookie. Now I am at the if statement. I am trying to figure out how I would compare the cookie value to today's date. Therefore if the cookie value date is older then 7 days it will redirect to another page...
Can't (i think). Best to set 3 cookies that will combine 2 cookies with a hash cookie 1 - your info cookie 2 - time cookie 3 - hash of cookie 1 and 2 to validate them then you can easily use cookie 2 (if validated) to find out the time of the cookie!
I done got it figured out... $today = date("m.d.y"); $cookie_date_check = $_COOKIE['redirect']; if(!isset($cookie_date_check['redirect'])){ $end_date = date("m.d.y",strtotime("+7 days")); setcookie("redirect",$end_date, time()+3600*24*90); } if(isset($cookie_date_check)){ if($cookie_date_check < $today){ header('Location: http://www.domain.com/?source_detail=55'); } } PHP: