i setting cookie, 60 day expiration time. cookie sets town user has selected our site. want have popup window open upon page loading ... want happen every week (and have cookie check if "it's been on 2 weeks").
we trying avoid setting 2 cookies. assume can checking how long 'til cookie expires, figure out when start date (based on $number_of_days), , calculate 2 weeks start date, , see if date/time has passed. however, php knowledge pretty limited. wondering if has done before , can show me how... need variable outputted states whether 2 weeks has passed or not (i.e. $openpopup=1);
i using following code cookie (single expiration date)...
$number_of_days = 60 ; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days ; if(isset($town)) { // set cookies setcookie( "towns", $town, $date_of_expiry, "/" ); } else { // del cookies unset($_cookie['towns']); // empty value , expiration 1 hour before setcookie('towns', '', time() - 3600); }
you cannot read expiration date once cookie has been set. can key=value pairs. if need date need set part of data in cookie itself.
you set multiple pieces of data in array , serialize , store in cookie. unserialize when read back.
Comments
Post a Comment