cookie的API

1. Create a cookie object

Cookie c = new Cookie(String name,String value);

2. Add the cookie to the response response

response.addCookie(cookie);

3. Get an array of all objects in the request cookie composition

Cookie[] cookie = request.getCookie();

4. Remove cookie

There is no direct way to delete cookie

5.cookie common method

 

Maximum living space 6.setMaxAge () to set a cookie

  If you do not set a cookie maximum survival time (not set setMaxAge method), the default cookie is a session-level cookie, cookie default memory stored in the browser, if the browser is closed, along with the release of memory, the cookie will follow destroyed.

  If the temporary file sets the maximum living space of the cookie (also set setMaxAge method), the browser cookie will be stored in the form of a file in a folder (that is, on the hard disk), even if multiple switch browsers, not cookie It will be destroyed next time you open the browser before the cookie can still be obtained.

Guess you like

Origin www.cnblogs.com/gxlaqj/p/11404691.html