December 2015
Intermediate to advanced
292 pages
6h 16m
English
A cookie is a string containing a key/value pair representing information of interest to the server such as user preferences. It is sent from a server to a browser. The browser should save the cookie to a file so that it can be used later.
A cookie is a string that consists of a name followed by an equal sign and then a value. The following is one possible cookie:
userID=Cookie Monster
A cookie can have multiple values. These values will be separated by a semicolon and white space.
We will use the HTTPServer class and the HttpURLConnection classes to demonstrate the handling of cookies. In the MyHTTPServer class server's handler class's handle method, add the following code after the other headers:
responseHeaders.set("Set-cookie", ...Read now
Unlock full access