Home >Web Front-end >JS Tutorial >sessionStorage 、localStorage、cookie

sessionStorage 、localStorage、cookie

PHP中文网
PHP中文网Original
2017-07-03 17:30:591331browse
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn