A cookie is small data with a specific job
Cookies sound more mysterious than they are. A cookie is a small piece of data that a browser stores for a website. It usually contains a short value, not a secret file or a complete profile of you.
The reason cookies exist is simple. HTTP, the system browsers use to request web pages, does not remember earlier requests by itself. Without another mechanism, each page request looks separate. A cookie gives the website a way to connect one request with the next.
For example, a cookie can hold a session identifier after you sign in. The actual account data can stay on the server. The identifier tells the server which session belongs to your browser. Cookies can also remember language settings, keep a shopping session active, or help measure visits. MDN explains these common uses in more technical detail.
A server can create a cookie through an HTTP response. Page JavaScript can also create cookies when browser rules allow it. On later eligible requests, the browser can send matching cookies back to the relevant domain. Attributes such as the domain, path, expiry, and security settings control where and how this happens.
First-party and third-party describe context, not ownership
Here is the part that causes most confusion: first-party and third-party do not describe which company wrote the code. They describe the relationship between the website in the address bar and the site that uses the cookie.
Imagine that you open example.com. A cookie stored for example.com is first-party in that visit. If the page embeds content from another site, a cookie used by that embedded site can be third-party because it operates across a different site context. The Chrome explanation of same-site and cross-site cookies makes this distinction clear.
