Middle+
What is the difference between Cookie and Set-Cookie headers?
sobes.tech AI
Answer from AI
The Set-Cookie header is used by the server to send a cookie to the client. It contains instructions for the browser to store a cookie with a specific name, value, and parameters (such as expiration time, path, domain).
Example:
Set-Cookie: sessionId=abc123; Path=/; HttpOnly
The Cookie header is sent by the client (browser) to the server in subsequent requests and contains all cookies that match the domain and path.
Example:
Cookie: sessionId=abc123; theme=dark
Thus, Set-Cookie is a command from the server to the client to set a cookie, and Cookie is the data that the client sends to the server.