phpcookiessetcookieexpired-cookies

Cookie Expiration times


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?


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)