Home > DeveloperSection > Interviews > How to store data on client in HTML5?

Posted on    August-29-2011 1:03 AM

 HTML5 HTML5 
Ratings:
 1 Answer(s)
  3774  View(s)
Rate this:

Chris Anderson
Chris Anderson

Total Post:197

Points:985
Posted on    August-29-2011 12:00 AM

HTML5 offers two new objects for storing data on the client:

LocalStorage - stores data with no time limit

<script type="text/javascript">

localStorage.lastname="Smith";
document.write(localStorage.lastname);

</script> 

 

SessionStorage - stores data for one session.The data is deleted when the user closes the browser window.

<script type="text/javascript">

sessionStorage.lastname="Smith";
document.write(sessionStorage.lastname);

</script>


Don't want to miss updates? Please click the below button!

Follow MindStick