html5 - Add data to localstorage and use it on another page -


is possible can save data local storage on site , use later on page on same site?

for example: have button "add localstorage" in page: http://www.domain.com/exhibitors/view/41873 , when click add data local storage , after on want use on http://wwww.domain.com/favorites/view/

is possible?

yes possible, have set localstorage :

localstorage.username = "user"; 

now have retrieve , wherever want, like:

alert(localstorage.username); 

in case have to somenthing this:

<a href="#" onclick="localstorage.username = 'paul'">add localstorage</a> 

then in view somewhere else do:

<script> alert(localstorage.username); </script> 

usually there 2 possibilities:

localstorage = think @ cookie (it persists on browser closing)

sessionstorage = think @ session (it persists until close browser)

obviously

it's highly suggested not store sensible data in browser, use them routines not storing passwords example, cause, user can edit them browser, , malicious users can too


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -