Cookie operation in JSP

xiaoxiao2021-03-06  52

Cookie Concept: The format of the cookie is actually a pure text message, which is sent to the client along with the webpage and saves the directory specified in the client hard disk. Everyone has a serious security threat, In fact, it is not such a thing. When the server reads cookies, only the information related to this server is only read. Moreover, the browser is generally only allowed to store 300 cookies, each site is mostly 20, and each cookie The size is now in 4k, and it will not take much space at all. And cookies are time-efficient. For example, the survival time of the cookie is 1 minute, then this cookie will be removed by the browser by the browser: Currently Two versions: Version 0: Developed by Netscape, almost all browser support. In order to maintain compatibility, Java is currently only supported by version 0, cookie's content cannot be spaced, square brackets, parentheses, etc. No. (=), comma, double quotes, slash, question mark, @ symbol, colon, semicolon. Version 1: Based on RFC 2109 documentation. Receive a lot of limitations. The characters listed above can be used. But in order to maintain compatibility, you should try to avoid using these special characters. JSP's Cookie's operation: Type method name method Explanation String getcomment () Returns a comment in cookies. If you do not have a comment, you will return null values. String getDomain () Returns the domain name applicable to cookies in cookies. Use the getDomain () method to indicate the browser to return cookies to other servers in the same domain. And usually the cookie is only returned to a server that is identical to the server name sent. Note that the domain name must return to the maximum time before INT getMaxage () returns to cookie expiration, in seconds. String getName () Returns the name of the cookie String getPath () Returns the path to the cookie. 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. Boolean getSecure () If the browser sends cookies through the security protocol, returns a true value if the browser uses the standard protocol. String getValue () Returns the value of the cookie. The author will also introduce GetValue / SetValue later. INT getVersion () Returns the version of the protocol complied with Cookies. Void SetComment Settings Cookies Note Void SetDomain (String Pattern) Sets the cookies for the cookies for use Void SetMaxage (int Expiry) in seconds, sets the cookie expiration time. Void SetPath (String Uri) Specifies the path to the cookie. Void SetSecure (Boolean Flag) Indicates the security protocol used by the browser, such as HTTPS or SSL. Void SetValue (String NewValue) Cookies created a new value.

转载请注明原文地址:https://www.9cbs.com/read-117114.html

New Post(0)