A
A
Alexander Kachkaev2010-10-21 17:21:35
JavaScript
Alexander Kachkaev, 2010-10-21 17:21:35

One localStorage for all subdomains. You can't, but maybe you can?

There is a multilingual project. Each language corresponds to a subdomain, and there are also special subdomains for static and special versions (like on Wikipedia):

en.example.com<br/>
ru.example.com<br/>
...<br/>
static.example.com<br/>
m.example.com<br/>
fb.example.com<br/>
vk.example.com<br/>
...<br/>

During operation, users will accumulate data that, in principle, is not needed on the server side, plus this data may be more than 4 KB, i.e. it is not advisable to use cookies.
HTML 5 localStorage seems to fit perfectly, but there is one big "but": data stored for one subdomain is not visible on all other subdomains according to the specification for security reasons.
Could you, dear Khabrovites, advise how you can store data locally in this case? Has anyone else encountered a similar problem and successfully solved it? Maybe it's worth using iFrame in some way, store localStorage there and "communicate" with it? Are there any other approaches to solving this problem?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
Kir ---, 2010-10-22
@SowingSadness

You can use 1 perverse way.
Use postMssage, which will broadcast localStorage requests on a special page, ala localStorage.example.com :)
By the way, you can play around with trying to reach directly to the ifram's localStorage, because the 2nd level domain of the pages will be the same. I don't remember, just whether the security policies allow it.

B
burivuh, 2010-10-24
@burivuh

I can suggest such a crutch:
make an invisible iframe, load a page into it from some common domain, for example, localStorage.yoursite.com, implement functions for working with storage in scripts on this page
, organize interaction with this iframe based on a hash hack (on the so-called XHRIFrameProxy is made on its basis )

E
ertaquo, 2010-10-21
@ertaquo

Try using the script from this article: Evercookies are the most persistent cookies

Z
Zitrix, 2010-10-21
@Zitrix

globalStorage if it was supported by chrome :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question