M
M
Makaveli2011-02-21 19:59:48
JavaScript
Makaveli, 2011-02-21 19:59:48

Using shared localStorage for subdomains?

Hello. I'm looking for advice. The task is not to drive data through cookies constantly to the server, but to store them in localStorage and have access to them via JavaScript.
The problem is that localStorage only gives access to a specific address. That is, for addresses:
sub.domain.ru
sub2.domain.ru the
data will be different. Is there any way to combine the data?
Tried the option with iframe:

var ifr = document.createElement('iframe');<br/>
ifr.src = 'domain.ru/localstorage.html';<br/>
ifr.name = 'localStorageIframe';<br/>
document.body.appendChild( ifr );<br/>

after which the data was accessed (and saved) through window.frames["localStorageIframe"].localStorage["lastseen"]
But this did not work - the data is still different for different subdomains.
Does anyone have any ideas how to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Riateche, 2011-02-21
@Riateche

And if there is a js code on the domain.ru/localstorage.html page, will it have access to the localstorage of the main domain? Then you can pull out the data using this code, and send tasks to it somehow through events, properties of the window object (in the child frame - parent) or DOM objects. (Unfortunately, I don't have an easy way to test this hypothesis right now.)

K
Konstantin Kitmanov, 2011-02-21
@k12th

And if you do it like with cross-domain scripting ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question