Passing parameters against local storage

I have a lobby written in HTML5 / javascript. The .json file provides several configuration options for the lobby and for various other HTML5 games that you can run from it. These parameters can be transferred to games in the window.open line (in the form:

window.open(http://www.myLovelyDomain.com/index.html?username=bob&token=aaaXXX") 

or can be held at localStorage and access to the game after launch.

My question is, what is the best (safest / probable way of least errors / etc)? I know that users can disable localStorage, but I don't know how much they do. Any thoughts?

+4
source share
1 answer

Benefits of localStorage over URL Query Strings

  • Less likely to be edited by user.
  • Less likely to copy and attach to someone else
  • It can be saved through sessions.
  • Wide selection of characters
  • (Marginally) less bandwidth usage (shorter GETs)
  • Can store whole files
  • Invisible to the base user

disadvantages

  • Server does not access variables without additional ajax
  • It may be harder to debug
  • Additional verification may be required if things change every session (or consider sessionStorage )
  • Not supported by older browsers
  • It is not possible to use cross-domain communication directly (maybe, depending on how you look at it)

For a supported list and maximum sizes see here .

+5
source

Source: https://habr.com/ru/post/1445720/


All Articles