1. What is Cookie?
Cookie is the content stored in the browser. When you browse the page this time, you can save the text content to the cookie. The last saved content can be obtained when you visit the page next time, in this way, we can get the last "Memory" content.
Conclusion: cookies are some data stored in browsers.
2. Is Cookie unique to jquery?
Cookie is not a unique concept of jquery, but jquerycookie simplifies it more easily.
Iii. Cookie requirements:
1. before using the cookie plug-in, you must first import the jquery control. Because the cookie is actually an extension method based on jquery, you must call the jquery method to use the cookie method to obtain the cookie ($. cookie () or jquery. cookie ()).
2. The cookie must be supported by the browser. The cookie of the browser can be disabled. If the cookie is disabled, it cannot be used. However, you do not need to disable the cookie.
Conclusion: All cookie operations are managed by the browser.
Iv. Cookie features:
1. Cookies are related to domain names. Therefore, 163.com cannot read cookies recorded by Baidu.com. Because of this, you do not have to worry about conflicts between cookies of different domain names when reading and setting cookies;
2. the total size of cookies that can be written to a domain name is limited. The size is generally several thousand bytes. The total number of cookies that can be written is usually dozens, the browser will remove some cookies according to its own policies after the limit is exceeded;
3. The cookie will not be read again after being written. The browser may clear the cookie regularly or manually.
4. The data written to the cookie must be dispensable. For example, the cookie cannot be used to prevent cheating.
5. Storage of cookies on the client:
1. Stored in browser memory
2. stored in the hard disk of the computer where the browser is located
The implementation of these two storage methods is described in the usage of cookies.
Vi. Usage of cookies:
1. Form of key-value pairs saved by cookies
2. Set the value to $. Cookie ("name", "value ");
3. Value: $. Cookie ("name ");
4. when the cookie method has two parameters (the user's key name when the first parameter is used, and the second parameter is the value corresponding to the Key), the system stores the parameters in the browser memory by default.
When the cookie method has the third parameter (used to set the storage period), $. cookie ("name", "value", {epires: 7}); in this case, the cookie is stored in the hard disk of the computer where the browser is located. You can view the cookie folder.
7. You must pay attention to the lessons learned from vomiting blood.
Before writing this blog, I first used the cookie plug-in the vs environment to provide a small example of Logon. As a result, when viewing the results in a browser, the desired results will not appear, that's urgent, that call, and everyone has experienced vs's ability to fault-tolerant HTML and prompt, so ...... The result took two hours to complete, and finally it was found that the order of the import plug-in was wrong.
Under normal circumstances, the jquery plug-in should be first imported, and then the cookie plug-in should be imported. There cannot be any obfuscation in the order, otherwise ...... It is worse than you. Try it if you don't believe it!