IE and Opera will clean cookie no recent use, Firefox random cleanup
cookie up to 4096 bytes, for compatibility is generally not more than 4095 bytes
IE5 above provides userData, store up to 1M Under each domain name. Stored in the cache, if not cleaned, long time.
The cookie advantages: persistence data; the client, the server does not occupy storage resource cookie; cookie may be provided an effective period; simplicity, d text-based lightweight structure.
The rational use of the advantages of the cookie
Through good it becomes possible to control the session object stored in a cookie the size of the
Through encryption and secure transmission technology, reducing the likelihood of cookie being cracked.
Not only to store sensitive information in a cookie theft will not cause significant losses.
Control is valid
cookie shortcomings
cookie number and size is very limited
Security issues. You do not need to crack and forwards to achieve their goals.
Range is limited. Not all states can be resolved by saving the cookie.
The storage html
html5 provides two storage methods: sessionStorage and localStorage. Both collectively webstorage, different browsers can not be shared, shared localStorage same browser. Homologous to meet the case can be shared sessionStorage. Both are stored on the local client. Type is a string type is stored
About the size of 5M (different in different browsers)
sessionStrorage: local storage of a session is valid data, only the session-level data, the data will be destroyed after the end of the session.
localStorage is a long-term effective local storage, non-active deleted, has been effective.
method of obtaining
sessionStrorage:window.sessionStrorage
localStorage:window.localStorage
Scenarios
Long-term effective use localStorage
Effective use of a sensitive operation sessionStrorage
Compared cookie
It can store more data.
Save traffic, save server resources: Because not transferred to the server, saving flow. And obtain faster than the local server, so more efficient.