Home>Article>Web Front-end> What does javascript use to store data?

What does javascript use to store data?

青灯夜游
青灯夜游 Original
2021-04-07 11:48:59 3849browse

There are three ways for JavaScript to store data: 1. sessionStorage, which can save data in the session object; 2. localStorage, which can save data in the client's local hardware device; 3. cookie is used to store data In local computer files or browser memory.

What does javascript use to store data?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

javaScript has three data storage methods, namely:

  • sessionStorage

  • localStorage

  • cookie

sessionStorage: Save data in the session object. The so-called session refers to the time that elapses from entering the website to closing the browser when the user is browsing a website, that is, the time the user spends browsing the website. The session object can be used to save any data required to be saved during this period.

localStorage: Save the data in the client’s local hardware device (usually the hard disk, but can also be other hardware devices). Even if the browser is closed, the data still exists. You can still use it the next time you open your browser to visit the website.

AndCookieis a piece of data stored on the client, but different browsers store cookies in different places:

  • One is to store Cookie The data is saved in a file;

  • The other is saved in the browser memory.

For example:

  • IE browser

    The IE browser cookie data on Windows system is located in %APPDATA% The xxx.txt file in the \Microsoft\Windows\Cookies\ directory may contain many .txt Cookie files, such as C:\Users\yren9\AppData\Roaming\Microsoft\Windows\Cookies\0WQ6YROK.txt.

    In the IE browser, IE saves the cookies of each site as a plain text file such as XXX.txt;

  • Firefox and Chrome browsers

    Firefox and Chrome save all cookies in a file, and the file format is a SQLite database format file.

    Firefox's cookie data is located in the xxx.default directory in the %APPDATA%\Mozilla\Firefox\Profiles\ directory, in a file named Cookies.sqlite, such as C:\Users\jay\AppData\Roaming \Mozilla\Firefox\Profiles\ji4grfex.default\cookies.sqlite.

    To view cookies in Firefox, you can select "Tools>Options>Privacy>Show Cookies".

    Chrome's cookie data is located in a file named Cookies in the %LOCALAPPDATA%\Google\Chrome\User Data\Default\ directory, such as C:\Users\jay\AppData\Local\Google\Chrome\User Data\Default\Cookies.

For more programming-related knowledge, please visit:Programming Video! !

The above is the detailed content of What does javascript use to store data?. 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