When a web server creates a cookie, an additional HTTP header is sent to the browser when a page is served to the browser.
The HTTP header looks like this:
Set-Cookie: message=Hello
After a cookie has been created on a browser, whenever the browser requests a page from the same application in the future, the browser sends a header that looks like this:
Cookie: message=Hello
You can store only string values when using a cookie.
Two types of cookies: session cookies and persistent cookies.
A session cookie exists only in memory.
A persistent cookie can last for months or even years.
A persistent cookie is stored permanently by the user's browser on the user's computer.