Search code examples
phpcookiessetcookie

PHP getting expiring time of a cookie


Can I get the expiring time of a cookie which is already set? For example, I have set a cookie:

setcookie("test_cookie","some value", time()+3600*24*30);

Now can i get the time when the test_cookie is expiring? One option could be that when i set the test_cookie, i can set the expiring time in another cookie, but i'm wondering if there's alternative, better way without setting other cookie?

Thanks.


Solution

  • Setting it in another cookie is the best method, that or simply appending it to the end of the data you're storing with a delimeter such as #.