Tuesday, December 6, 2016

JavaScript Session - HTML Local Storage - Q&A

Question:

What is a session and how does it works?

Answer

The sessionStorage is used for storing data on the client. The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the specific browser tab. For example;

if (sessionStorage.clickcount) {

    sessionStorage.clickcount = Number(sessionStorage.clickcount) + 1;

} else {

    sessionStorage.clickcount = 1;

}

No comments:

Post a Comment