Welcome Guest! To access all forums & features, please register an account or sign-in. → Why register?



web storage works offline, but not online


29 replies to this topic - - - - -

#1 metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 12 June 2012 - 14:20

hello

i have a site where i use web storage ( http://en.wikipedia....iki/Web_storage ) and it works offline but when i put it online, it doesnt work. vry very strange. a server cannot limit if i use web storage or not rite??? its works offline on all browsers when it is on my local server but when on online, it doesnt work.


wat could be rong????


#2 dwntwn

    Neowinian²

  • 214 posts
  • Joined: 02-July 04

Posted 12 June 2012 - 20:09

I use both local and session storage objects in my applications; are the domains different from offline and online? If you set a key value pair when browsing localhost, then you will not be able to access them when you are browsing www.yoursite.com (and vice-versa).

subdomains are also subject to this; web.yoursite.come can not access mail.yoursite.com objects.

#3 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 13 June 2012 - 07:03

View Postsoffcore, on 12 June 2012 - 20:09, said:

I use both local and session storage objects in my applications; are the domains different from offline and online? If you set a key value pair when browsing localhost, then you will not be able to access them when you are browsing www.yoursite.com (and vice-versa).

subdomains are also subject to this; web.yoursite.come can not access mail.yoursite.com objects.
no.

on local i use: example.ex/something and example.ex/somethingelse that works (on both)
online i use (for the same above): something.example.com and somethingelse.example.com that does not work (on either)

my feeling is that indeed that ****ing subdomain has sumthin to do with it. any workaround????

#4 The_Decryptor

    THE ALPHA CEPH!

  • 18,342 posts
  • Joined: 28-September 02
  • Location: Sol System
  • OS: WinLin X 10.9 Ill-tempered Badger

Posted 13 June 2012 - 07:30

You could move your localStorage code to the root domain (so example.com), then embed the code through an iframe on both subdomains, and send messages between the two documents as a way to do it.

#5 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 13 June 2012 - 08:20

View PostThe_Decryptor, on 13 June 2012 - 07:30, said:

You could move your localStorage code to the root domain (so example.com), then embed the code through an iframe on both subdomains, and send messages between the two documents as a way to do it.
do u have anywhere i can see examples or tutorials or more indepth information?

thank u

#6 The_Decryptor

    THE ALPHA CEPH!

  • 18,342 posts
  • Joined: 28-September 02
  • Location: Sol System
  • OS: WinLin X 10.9 Ill-tempered Badger

Posted 13 June 2012 - 08:35

http://www.nczonline...n-localstorage/

Edit: You'll want to ensure that no other sites can embed the code and issue commands to your code, it covers it in the article but it won't hurt to mention it again.

#7 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 13 June 2012 - 08:48

View PostThe_Decryptor, on 13 June 2012 - 08:35, said:

http://www.nczonline...n-localstorage/

Edit: You'll want to ensure that no other sites can embed the code and issue commands to your code, it covers it in the article but it won't hurt to mention it again.
:laugh: this is the same exact page i looked up when i posted about maybe subdomains being a pain.....

i have several problems with that implementation......*sighs* im not sure this is going to be easy as the situation is kind of complicated.

my root domain is tecnically a subdomain....so thats going to be problematic.

if you have sum time to spare (and want to), The_Decryptor, a 1 on 1 pm session wud be nice and helpful.

tanks to all for the advice and comments

#8 The_Decryptor

    THE ALPHA CEPH!

  • 18,342 posts
  • Joined: 28-September 02
  • Location: Sol System
  • OS: WinLin X 10.9 Ill-tempered Badger

Posted 13 June 2012 - 11:27

Well, if you're in the situation where you don't control the root domain, only the subdomains, then you'd have to have one "master" subdomain, and have the second subdomain use that for storage (Using the same postMessage setup as you would use for subdomain > domain communication)

#9 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 13 June 2012 - 11:40

View PostThe_Decryptor, on 13 June 2012 - 11:27, said:

Well, if you're in the situation where you don't control the root domain, only the subdomains, then you'd have to have one "master" subdomain, and have the second subdomain use that for storage (Using the same postMessage setup as you would use for subdomain > domain communication)
so it wud be the same implementation? ok will give it a go and see if sumthin explodes.

btw this also works on my local rite? ill implement in first in my local then pass it...

#10 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 13 June 2012 - 16:26

got it to work (had some stuff to do)

i just have a very noob javascript question:

/*java script up here*/
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
	 remoteStorage.requestValue("lookforme", function(key, value){
	 alert("The value for '" + key + "' is '" + value + "'");
	
	 });
alert ("alert 2 : I want to print/use value on the outside" + value);
/*javascript down here*/


pretty selfexplains....i want to use value on the onside of that little variable/function (for example in that thing that says alert 2). how to do it????

#11 -Alex-

    Noob Hunter

  • 2,760 posts
  • Joined: 08-August 06
  • Location: Oslo, Norway

Posted 13 June 2012 - 16:46

Should work, but not tested:

/*java script up here*/
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
		 value = remoteStorage.requestValue("lookforme", function(key, value){
		 alert("The value for '" + key + "' is '" + value + "'");
		 return value;

		 });
alert ("alert 2 : I want to print/use value on the outside" + value);
/*javascript down here*/


#12 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 14 June 2012 - 06:55

nope did not work, -Alex-

#13 The_Decryptor

    THE ALPHA CEPH!

  • 18,342 posts
  • Joined: 28-September 02
  • Location: Sol System
  • OS: WinLin X 10.9 Ill-tempered Badger

Posted 14 June 2012 - 07:14

/*java script up here*/
var remoteStorageValue = "";
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
                 remoteStorage.requestValue("lookforme", function(key, value){
                 alert("The value for '" + key + "' is '" + value + "'");
                 remoteStorageValue = value;
                 });
alert ("alert 2 : I want to print/use value on the outside" + remoteStorageValue);
/*javascript down here*/

You have to set the global value within the callback function, returning it won't work (Since you're assigning the return of "requestValue" to the variable, not the value of the callback which can happen at a later time)

#14 OP metro2012

    Neowinian³

  • 458 posts
  • Joined: 13-May 12

Posted 14 June 2012 - 09:18

View PostThe_Decryptor, on 14 June 2012 - 07:14, said:

/*java script up here*/
var remoteStorageValue = "";
var remoteStorage = new CrossDomainStorage("http://example.dev", "/server.html");
				 remoteStorage.requestValue("lookforme", function(key, value){
				 alert("The value for '" + key + "' is '" + value + "'");
				 remoteStorageValue = value;
				 });
alert ("alert 2 : I want to print/use value on the outside" + remoteStorageValue);
/*javascript down here*/

You have to set the global value within the callback function, returning it won't work (Since you're assigning the return of "requestValue" to the variable, not the value of the callback which can happen at a later time)

i changed it to that code and it says that RemoteStorageValue ' s value is simply undefined

#15 The_Decryptor

    THE ALPHA CEPH!

  • 18,342 posts
  • Joined: 28-September 02
  • Location: Sol System
  • OS: WinLin X 10.9 Ill-tempered Badger

Posted 14 June 2012 - 11:02

It shouldn't say that since the first line sets it to "", which is different from undefined.

There is another issue of course, the second alert will fire before the callback could/will, so it won't see the value that the callback will.