Reference article: Handling cookie
http://dev.9cbs.net/Article/37/37399.shtm
Create a cookie: Call the constructor of the cookie object to create a cookie. The constructor of the cookie object has two string parameters: cookie name and cookie value. Names and values cannot contain blank characters and the following characters: [] () =, "/? @:
Reading and setting the cookie property Before adding the cookie, you can view or set up the various properties of the cookie before you get the answers to be sent. These methods are described in the following summary: getcomment / setcomment Get / sets the comments for cookies. GetDomain / setdomain Gets / sets the available fields for cookies. Generally, cookies only returns the same server that is identical to the server name transmitted. Using the method here, you can indicate that the browser returns the cookie to other servers in the same domain. Note that the domain must start with a point (for example, .sitename.com), non-national domain (such as .com, .edu, .gra) must contain two points, national domains (such as .com.cn, .edu. UK) must contain three points. GetMaxage / SetMaxage Gets / Sets the time before the cookie expires, in seconds. If this value is not set, the cookie is only valid within the current session, that is, valid before the user closes the browser, and these cookies are not saved on the disk. See below with the instructions on LongliveDCookie. GetName / SetName Gets / sets the name of the cookie. Essentially, the names and values are two parts we have always cared. Since the GetCookies method of HTTPSERVLETREQUEST returns a Cookie object array, therefore usually uses a loop to access this array to find a specific name, and then check its value with getValue. GetPath / SetPath Gets / Sets the path to Cookies. If the path is not specified, the cookie will return to all the pages in the current page where the current page is located and its subdirectory. The method here can be used to set some more general conditions. For example, someCookie.SetPath ("/"), at which time all pages on the server can receive the cookie. GetSecure / SetSecure Gets / Sets a Boolean value that represents whether cookies can only be sent by encrypted connections (ie SSL). GetValue / SetValue Gets the value of / set the cookie. As mentioned earlier, the names and values are actually two aspects we have always cared. However, there are also some exceptions, such as using the name as a logical tag (that is, if the name exists, it means true. GetVersion / SetVersion Gets / Sets the protocol version of the cookies. The default version 0 (complies with the original Netscape specification); version 1 follows RFC 2109, but has not been widely supported. Read Save to Client Cookies To send cookies to the client, first create a cookie, then send a set-cookie HTTP response head with AddCookie. These contents have been described above in Top 2.1. The getCookies method that calls HTTPSERVLETREQUEST when reading cookies from the client. This method returns an array of cookie objects corresponding to content in the HTTP request header. After getting this array, it is generally used to access the individual elements in the loop, call GetName to check the names of each cookie until the target cookie is found. Then, the GetValue is then called to this target cookie, and other processing is performed according to the result. The above processing process often encounters, and provides a getCookieValue method for the convenience meter.