The Servlet Cookie API
The servlet creates a cookie by using a constructor for the class Cookie.
Various attributes can be set for the cookie before sending it to the client. They include:
- The name and value of cookie.
These are usually set in the Cookie constructor.
- The domain to which the cookie should be returned.
By default the cookie will only be returned to the server that sent it, but this default can be overridden.
- The URI path to which the cookie should be returned.
By default, the cookie is only returned to pages in the same directory as the page that sent the cookie.
- The time when a persistent cookie expires
e.g., the cookie should be deleted by the browser after one hour, after one year, etc.