What is Cookie Expire?

Cookies are sent by the web server, stored at the client-side by the web browser, and appended to every request to add state to an otherwise stateless HTTP service. These cookies help the server remember users and their preferencessuch as shopping carts and views.

Cookie Expire

The cookie has an Expire attribute that defines a specific date and time, after which the browser should stop sending the cookie and delete it. The date and time are specified in the format, DD Mon YYYY HH:MM:SS GMT or DD Mon YY HH:MM:SS GMT.

You can also set the Max-Age attribute to set the expiration date as an interval of seconds in the future after the browser receives the cookie.

Here are a few examples:

HTTP/1.0 200 OK Set-Cookie: cookie=jknhs6rcdnyslkmers; Expires=Tue, 15 Feb 2020 00:17:48 GMT; Path=/; Domain=educative.io;

This sets the cookie to expire on a specified date as stated in the header.

HTTP/1.0 200 OK Set-Cookie: cookie=jknhs6rcdnyslkmers; Path=/; Domain=educative.io;

This cookie does not have an expiration date; so, it is a session cookie. However, as soon as the user deletes the cookie, the state will be lost.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved