Reputation: 5792
I am using codeigniter framework. This is my currenct code to set cookies in browser. If there is a known IP address then it won't ask you to enter security answer. o.w. user needs to enter security answer.
Everything is working fine, except when I close the broswer entirely or restart my PC, cookies get deleted and it asks me again to enter that information.
CODE
$ip_address = $_SERVER['REMOTE_ADDR'];
$ip_cookie = array('name'=>'ip',
'value'=>$ip_address,
'expire' => time() + (10 * 365 * 24 * 60 * 60)
);
set_cookie($ip_cookie);
As you can see I also setup expire time for this.
Upvotes: 0
Views: 1651
Reputation: 146630
Might not be the cause but you are setting an expiration date in 54 years or so. From the manual:
The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the number of seconds from now that you wish the cookie to be valid. If the expiration is set to zero the cookie will only last as long as the browser is open.
Perhaps the browser has an upper limit for expiration time. You should also check your browser developer tools for actual values received.
Upvotes: 2