Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use localstorage with context per path like cookie?

Aware of issues like:

  • Cookies are included with every HTTP request, thereby slowing down your web application by needlessly transmitting the same data over and over
  • Cookies are included with every HTTP request, thereby sending data unencrypted over the internet (unless your entire web application is served over SSL)
  • Cookies are limited to about 4 KB of data — enough to slow down your application (see above), but not enough to be terribly useful

(from: http://diveintohtml5.info/storage.html)

I decided to use localstorage instead of cookies.

QUESTION: Can I limit localstorage context to certain path like with cookies?

like image 511
andilabs Avatar asked Jul 29 '14 10:07

andilabs


1 Answers

As mentioned in the comments already, webstorages (localStorage, sessionStorage) are scoped per origin.

User agents must have a set of local storage areas, one for each origin.

Source: http://www.w3.org/TR/webstorage/#the-localstorage-attribute


What is an origin?

Let's just quote the w3.org wiki page on the same origin policy:

An origin is defined by the scheme, host, and port of a URL.

Source: http://www.w3.org/Security/wiki/Same_Origin_Policy

like image 185
David Mulder Avatar answered Oct 18 '22 11:10

David Mulder