Webstorage not working with LAN preview

Get help using Construct 2

Post » Fri Feb 21, 2014 11:55 am

Hi guys,

I saved some variables using webstorage and when I test it out, everything works fine. But when I preview it using lan, it appears that there is nothing there.

I am guessing that it has to do with localhost and the preview over lan actually being a ip address. But I have no idea what to do for this? I am planning to release my game into android, is there anything I should be aware of first regarding webstorage?

Thanks guys.
B
45
S
23
G
31
Posts: 687
Reputation: 20,600

Post » Fri Feb 21, 2014 12:04 pm

The values tored are specific for the browser and its connection.

As soon as your IP/adress changed -> from preview localhost to preview ip over lan, the webstorage information doesnt relate to that connection anymore.

You would have to store the same webstorage variables in the preview over lan session first in order for it to be available there as well.
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Fri Feb 21, 2014 12:35 pm

@lennaert thanks. I probably sound very dumb for this, but how do you store the webstorage variable in preview over lan session?

I don't see any options for such in the webstorage events. Or is there something I have to set to allow it to be stored in another connection browser?
B
45
S
23
G
31
Posts: 687
Reputation: 20,600

Post » Fri Feb 21, 2014 12:48 pm

rekjl wrote:@lennaert thanks. I probably sound very dumb for this, but how do you store the webstorage variable in preview over lan session?

I don't see any options for such in the webstorage events. Or is there something I have to set to allow it to be stored in another connection browser?



No worries, your just mssing a bit of direction.

Its not in events. Its from the running app.

While the app is running in preview over lan, whatever is stored during that connection (with that browser), is available in that browser over that connection.

Variables stored while previewing directly from C2 will not be available in a running app while using the preview over lan connection.
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,567

Post » Fri Feb 21, 2014 1:04 pm

@rekjl

The browser sees localhost and ip (e.g 10.0.0.4) and localhost:50000 and 10.0.0.4:50000 as four completely separate websites.
Also webstorage isn't webstorage per say. It is stored into the browsers cache that viewed the game.

So your pc chrome browser stores your game session data into your pc's chrome cache. Your mobile phone will store its own game session data. You can't access the data from your pc to your phone.

Webstorage stores data into the browser cache. (if you delete the cache, you loose your data).

Edit
Construct2 preview using chrome as default: press F12 while in preview in chrome and goto Resources and localstorage and click your game ip:50000? or whatever yours is and view what is currently stored.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Fri Feb 21, 2014 1:52 pm

Thanks so much @lennaert and @DUTOIT. I understand how webstorage works much better now.

One of my problems was how to set a local storage, I might have accidentally did it the first time by mistake, but after a few tinkering, I was finally able to set one. Because the only button on my first screen had a load webstorage function, I was finally able to set a local webstorage by checking if the local key exist and if not create one on start of layout.

Although....I am not sure why, now my whole game is messed up! I am really not sure why it happened cause parts that have nothing to do with the webstorage is acting weird, but I'll have a look and hopefully is something I can notice and fix soon.

Wow!! That is a nice trick Dutoit! I will definitely be using it to check my local keys if I ever need to check!
B
45
S
23
G
31
Posts: 687
Reputation: 20,600


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 10 guests