+ 1

What ?

Can someone explain to me what it means when it says: "Local storage is per domain. All pages from one domain can store and access the same data."? I don't understand.

14th Feb 2018, 8:54 AM
GO!
GO! - avatar
7 ответов
+ 3
What do you mean by << example website or softway >> ? @@ You could start to check this link about webstorage in general, wich provide other links to useful pages about reference and example/tuto about how to use it: https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API
16th Feb 2018, 2:26 PM
visph
visph - avatar
+ 2
Meanning is that if your page is hosted on 'mywebsite.com', so only pages hosted at this domain name can read and write the same data since browsers will create a private storage for each website. If you have a first page wich save a value in localstorage key 'mydata' (variable name identifier), so any page of the same website will read the saved value, but any other website cannot read it, until it save a value for that key (without overwriting those saved by others websites).
14th Feb 2018, 4:21 PM
visph
visph - avatar
+ 2
Browser doesn't << store website in "History" >>, but create a private space allocated to each domain (less or more equivalent to website) to store data (only accessible by each specific domain) in similar way as it do for cookies (but with improvements, among which higher space capacity ;) Webstorage (both localstorage and sessionstorage) was primarly intented to replace cookies for user/client side data storing, meaning that cookies should be used if you want be able to access those data on server side ( unlike webstorage, cookies are send and updated with Http requests/responses )...
16th Feb 2018, 12:49 PM
visph
visph - avatar
+ 1
"Web storage offers two different storage areas—local storage and session storage—which differ in scope and lifetime. Data placed in local storage is per origin (the combination of protocol, hostname, and port number as defined in the same-origin policy) (the data is available to all scripts loaded from pages from the same origin that previously stored the data) and persists after the browser is closed. Session storage is per-origin-per-window-or-tab and is limited to the lifetime of the window." - wikipedia Hope that helps :)
14th Feb 2018, 11:42 AM
Coinage
Coinage - avatar
+ 1
yes,I totally understand that statement! thank you visph! So...my next query is :"Is there any example website or softway for session storage?"
16th Feb 2018, 1:53 PM
GO!
GO! - avatar
+ 1
Thank you GUYS! 😊
16th Feb 2018, 2:43 PM
GO!
GO! - avatar
0
@visph "browser will create a private storage for each website" Is that mean the browser will store the website in "History"?
16th Feb 2018, 12:15 PM
GO!
GO! - avatar