Whenever the browser receives a response containing a specific cookie header, it creates a cookie.
Using the Java Servlet API, you can create cookies with:
Cookie cookie = new Cookie(); cookie.setName();
On subsequent requests, the browser sends cookies to the server. Again, using the servlet API, you can get the current cookies by calling request.getCookies()
Bozho source share