Webstorage not working with LAN preview

0 favourites
  • 6 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • 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.

  • 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.

  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • Thanks so much lennaert and 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)