How do I create a persistent vs a non-persistent cookie?

Viewed 92995

I can't seem to figure out how to create a persistent vs a non-persistent cookie. How do they differ, say, in the HTTP headers that are sent back?

4 Answers

Persistent cookies have an expiration date issued to it by the web server. Basically, this type of cookie is saved on your computer so when you close it and start it up again, the cookie is still there. Once the expiration date is reached, it is destroyed by the owner.

Reference: https://www.cookiepro.com/knowledge/what-is-a-persistent-cookie/

If a cookie does not contain an expiration date, it is considered a session/non-persistent cookie.

So, basically persistent cookies come with the expires attribute e.g.

expires="Wdy, DD-Mon-YYYY HH:MM:SS GMT"
Related