The server can set cookies with the Set-Cookie header (Set-Cookie: theme=dark;
) and the browser automatically sends this cookie back at every request (Cookie: theme=dark;
)
The server does that to implement the idea of a session. The goal is to keep a set of data related to a user's current 'browsing session'.
Examples: logins, shopping carts and user tracking.