Reputation: 5585
I have two pages in PHP where the first one creates a cookie using session_set_cookie_params(30 * 60,"/","/",false);
and the next page tries to retrieve the cookie (using session_get_cookie_params()
) to display the time left on the cookie but for some reason I only get zero time left.
This is the cookie set page
<?php
session_set_cookie_params(30 * 60,"/","/",false);
session_start();
$array = session_get_cookie_params();
echo $array['lifetime'];
?>
and this is the page that starts the session and retrieves the cookie
<?php
session_start();
$array = session_get_cookie_params();
echo $array['lifetime'];
?>
Upvotes: 0
Views: 322
Reputation: 1970
The third parameter you used "/" is not a valid domain name. Using session_set_cookie_params(30 * 60,"/") will work. Default for 4th parameter - secure is false, no need to sepcify.
Upvotes: 1