Cookie Editor Utility


Parse/edit/generate Web Cookie strings. For more information on Cookies, see the Overview section. For code examples, see the Examples section.


Editor

Cookies

KeyValue

Overview

Web cookies, often simply called "cookies," are small pieces of data sent from a website and stored in a user's web browser while the user is browsing that website. Every time the user loads the website, the browser sends the cookie back to the server to allow the server to retain state for the user that is persisted over time. They enable websites to keep track of stateful information (like items added to a shopping cart) or to record user browsing activity (such as logging in, clicking particular buttons, recording which pages were visited in the past, or user preferences).

Creation

  1. Server-Side: When you visit a website, the server can send a Set-Cookie header along with the HTTP response. This instructs the browser to store the cookie with the specified name and value. For example:
    Set-Cookie: sessionId=12345; expires=Fri, 31 Dec 2023 23:59:59 GMT; path=/
  2. Client-Side: JavaScript running on a webpage can also create cookies. For instance, using the document.cookie property:
    document.cookie = "username=JohnDoe; expires=Fri, 31 Dec 2023 23:59:59 GMT; path=/";

Storage

Cookies are stored locally on the user's device. Each browser will manage cookies a little differently, but generally, they are stored in a location specific to the particular browser on the user's hard drive. Cookies have attributes that determine their lifespan:

  • Session Cookies: These are temporary and are deleted when the browser is closed. They do not have the "expires" attribute.
  • Persistent Cookies: These have an expiration date specified and will persist on the user'sdevice until that date.

Apart from expiration, cookies also contain other attributes like:

  • Domain: Specifies which website the cookie belongs to.
  • Path: Determines the URL path the cookie is available to.
  • Secure: Indicates that the cookie should only be sent over HTTPS.
  • HttpOnly: Indicates that the cookie should not be accessible via JavaScript.

Transmission

After a cookie is set for a domain, every subsequent HTTP request made by the browser to that domain will include the cookie in the HTTP headers until the cookie expires or is deleted. This is how the server recognizes returning users or sessions.

For example, if a cookie has been set with the name "sessionId" and value "12345", the browser will automatically include it in the request headers for each request to the domain:

GET /somepage.html HTTP/1.1
Host: www.example.com
Cookie: sessionId=12345

If there are multiple cookies for the same site, they are transmitted as a single Cookie header in the HTTP request, with each key-value pair separated by a semicolon and space. For instance, if a site has set a"sessionId" cookie and a "username" cookie, the header might look something like this:

Cookie: sessionId=12345; username=JohnDoe

Summary

Complex websites or frameworks typically have complex cookies which can be difficult to parse and understand by the human eye. The Cookie Editor tool helps with the task by allowing users to paste in an entire cookie header value and parses it into an easy to understand table format. To understand how to interact with cookies in code, take a look at some of our Examples.

Examples


Choose from the options above to view an example.