Question

Is is possible to find out when a cookie expires, I have set my cookie up doing this

$_COOKIE[] = setcookie("bangUser", $unique, time() + (60*60*24*30));

is possible to print out is expiration date on screen somehow?

Was it helpful?

Solution

Yes, you can use the date function to print out a pretty version of the timestamp that you are passing into your setcookie function. An example of the code you could implement is below. You could change the date format using the guide on this page.

$expireat = time() + (60*60*24*30);
setcookie("bangUser", $unique, $expireat);
echo date("l jS \of F Y h:i:s A",$expireat)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top