Setting cookies with an HTTP client

Cookies are an essential component of modern web applications. Cookies are sent back and forth between the client and server as HTTP headers. Cookies are just text key-value pairs that are stored by the browser client. They are used to store persistent data on the client. They can be used to store any text value, but are commonly used to store preferences, tokens, and session information.

Session cookies usually store a token that matches the token the server has. When a user logs in, the server creates a session with an identifying token tied to that user. The server then sends the token back to the user in the form of a cookie. When the client sends the session token in the form of a cookie, the server ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.