What Are Cookies and How Do They Work

· Category: Tech Fundamentals

Short answer

Cookies are small text files stored by the browser. Websites use them to remember state, such as login sessions and user preferences.

How it works

When you visit a site, the server sends a Set-Cookie header. The browser stores the cookie and sends it back with subsequent requests via the Cookie header.

Example

A shopping cart ID is stored in a cookie so items persist across page loads without requiring a server-side session lookup on every request.

Why it matters

Cookies enable personalization and authentication. However, they also raise privacy concerns and are subject to regulations like GDPR and the ePrivacy Directive.