Adding cookies to the request

Top  Previous  Next

HTTP cookies are used as a way of transmitting state information during the lifetime of an HTTP session. An example cookie might be one that tracks your user preferences for a web-based application.

 

The lifetime of a cookie starts on the HTTP server where it is then sent to the client. Once set, for each subsequent request to the server the client then passes the cookie back to the server. The HTTP server may then use this information for providing dynamic content back to the client. The HttpRequest#addCookie method mimics the process of the client sending back a cookie to the HTTP server.

 

Example

 

// create new HttpRequest

HttpRequest request = new HttpRequest("http://www.myserver.com");

 

// add cookie

request.addCookie("username", "jsmith");





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC