Java code for Send Cookies ExampleThis Java code snippet was generated automatically for the Send Cookies example.
<< Back to the Send Cookies example
What is HTTP?
The Hypertext Transfer Protocol is the data transfer protocol that underlies the World Wide Web. HTTP transfers data between HTTP clients (browsers and mobile apps) and servers. HTTP is based on a client-server architecture. HTTP works as a request-response protocol between client and server. The client initiates a connection and sends a request. The server receives the request, executes it, and sends the result to the client.
What is Cookie?
HTTP Сookies are small pieces of text data sent by a website and stored on a user's computer by a web browser. The data stored in the cookie is created by the server when it processes a request from the client. This data is tagged with an identifier that is unique to you and your computer. The browser sends cookies back to the server with each subsequent request. The server reads the identifier from the cookie and determines whether the request came from the same browser or not. After that, the server knows exactly what information can be provided to the user (based on user permissions). Cookies are mainly used to manage user sessions, track users, store user preferences and site settings.
Cookies are mainly used for three purposes:
- Session management: Logins, passwords, or whatever the server needs to remember
- Personalization: Custom settings, themes, and other settings
- Tracking: Recording and analysis of user behavior
How to see saved Cookies in the browser?
To see saved Cookies in your browser:
- Navigate to a website;
- Press F12 to open the developer tool;
- Click the Application tab;
- In the tree in the Storage section, select Cookies and your website address;
- Here, you will see all the Cookies stored for your browser for this site.
How to send Cookies?
An example of sending Cookies header to the ReqBin echo URL: