Are localstorage keys unique for every game?

Get help using Construct 2

Post » Fri Jan 22, 2016 6:49 pm

Well the title says all, are localstorage keys unique for every game? I mean if you save some data to the localstorage key "Score" for example and in another project you do the same because you just copy paste the code from one project to another.

Example:

Game 1 Localstorage key name "Score"
Game 2 Localstorage key name "Score"

If i save something in game 2 is this gonna overwrite the value of the game 1 localstorage key? Or every game has his unique "Score" key?
B
17
S
7
G
2
Posts: 13
Reputation: 2,250

Post » Fri Jan 22, 2016 9:02 pm

It's based on the domain. If you have multiple games on the same website they will share storage. All games in preview share. It's best to use a prefix.
B
55
S
28
G
18
Posts: 1,520
Reputation: 25,305

Post » Fri Jan 22, 2016 9:37 pm

Im currently developing for android and ios, that happens also on mobile?
B
17
S
7
G
2
Posts: 13
Reputation: 2,250

Post » Fri Jan 22, 2016 10:29 pm

Not sure, I think it's probably unique per game on mobile and node webkit.
B
55
S
28
G
18
Posts: 1,520
Reputation: 25,305

Post » Sat Jan 23, 2016 11:21 am

chal wrote:Im currently developing for android and ios, that happens also on mobile?


The localstorage is unique for each game, at least on android.
On a website the share the same LocalStorage, so it's recommended to use a prefix.

But to be absolutely sure, just always use a prefix like the game name "GAME_highscore"

Regards
Andy
Image Image iTunes: Match3 | Google Play: Match3
B
81
S
27
G
26
Posts: 1,025
Reputation: 24,493

Post » Sat Jan 23, 2016 3:39 pm

Thanks for the help :)
B
17
S
7
G
2
Posts: 13
Reputation: 2,250

Post » Sat Jan 23, 2016 5:27 pm

I use a function to handle local storage. that function uses a prefix. so if you template your games, one simple change changes it everywheres :)
B
38
S
16
G
8
Posts: 469
Reputation: 8,051


Return to How do I....?

Who is online

Users browsing this forum: JoshVillaluz, KittenKatja, LaDestitute, ladjuric, Zjahel0001 and 9 guests