Baking Your First Cookie
A cookie is a text string with a particular format:
cookieName=cookieValue; expires=expirationDateGMT; path=URLpath; domain=siteDomain
Breaking this down, the first part of the string gives the cookie a name and assigns it a value. This is the only mandatory part of a cookie; the rest of the string is optional. Next is the expiration date of the cookie; when this date is reached, the browser automatically deletes the cookie. The expiration date is followed by a URL path, which lets you store a URL in the cookie. Finally, you can store a domain value in the cookie.