php - A non well formed numeric value encountered in - setcookie function -
$user_id = $row['userid']; $token = uniqid($user_id,true); $salt = md5(mt_rand()); $cookie_id = hash_hmac('sha512',$token,$salt); $nextweek = time() + (7 * 24 * 60 * 60); $expiry = date('y-m-d', $nextweek); //problem exists here $sql_store_cookie = "insert pcookies(cookie_id,user_id,expiry,salt) values('$cookie_id','$user_id','$expiry','$salt')"; mysqli_query($connection,$sql_store_cookie) or die(mysqli_error($connection));//die('{"l":"mysqli_error(`$connection`)"}'); setcookie($cookie_id,$token,$expiry);
if run above program, getting non formed numeric value warning
in setcookie
line. hope using correct format of type.
my timezone setting asia/kolkata , expiry data type timestamp.
i trying set 7 days current time.
please tell me doing wrong here. thanks.
if read the manual, see box third parameter
note: may notice expire parameter takes on unix timestamp, opposed date format wdy, dd-mon-yyyy hh:mm:ss gmt, because php conversion internally.
so need following instead
setcookie($cookie_id,$token,$nextweek);
Comments
Post a Comment