Features | cookie | localStorage | sessionStorage |
Storage | Browser side, same origin restriction | Browser side, same origin restriction | Browser side, same origin restriction |
capacity | <=4K | 5M~10M | 5M~10M |
Transmission |
Like in requests initiated by web services, With cookies in http header content |
Will not be sent to the server | Will not be sent to the server |
Durable | You can set the timeout (expires) | Permanent, Manual or Code Clear |
Clear immediately after closing window Even if they are different windows from the same origin |
operate |
No operation method, string operation method Format: "key=value;expires=time" |
A set of operating methods setItem(), getItem(), removeItem(), clear() Also localStorage['key 1']='value 1' |
Same as Zuo |
event |
none |
setItem(), removeItem() Onstorage is triggered after clear() is called event |
Same as Zuo |
The above is the detailed content of sessionStorage 、localStorage、cookie. For more information, please follow other related articles on the PHP Chinese website!