How to save user preference for my game in Cookies ?

Game development with Board Game Arena Studio
Post Reply
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

How to save user preference for my game in Cookies ?

Post by bidulpik »

Hi,
I've got problem saving the user game preference in cookies.

It works fine in studio.boardgamearena.com, I can easily restore cookies information, but I doesnt work in https://boardgamearena.com

In prod platform, some cookies are writtent in

Code: Select all

.boardgamearena.com
and my cookies are written in

Code: Select all

boardgamearena.com
I've tried to save it in .boardgamearena.com with javascript or dojo framework, but I didnt succeed.

I want Javascript (or dojo) to get my cookie information.

any idea ?

all the best
User avatar
robinzig
Posts: 461
Joined: 11 February 2021, 18:23

Re: How to save user preference for my game in Cookies ?

Post by robinzig »

Just a maybe tangential suggestion, but can't you use localstorage rather than cookies? It's generally a cleaner/nicer way to save things on the client side between sessions.
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

Re: How to save user preference for my game in Cookies ?

Post by bidulpik »

> It's generally a cleaner/nicer way to save things on the client side between sessions.
Can I do that ?
The only way a browser save data on the client side, is to use cookie, isnt it ?

There are many options in my game, and players will need to keep there option configuration from one game to another.

I can store it in the game DB, but could I have access to the database of previous game for a specific player player ?
Can I have access to player DB fields I could consult on each game ?

all the best,

bdk
User avatar
thoun
Posts: 1621
Joined: 10 December 2020, 22:25

Re: How to save user preference for my game in Cookies ?

Post by thoun »

As he said, localStorage will do just that (same as cookie but not sent to servers), it's better than cookies for your use.
LocalStorage will only apply for the device (but it would be the same for cookies). If you want preferences to apply on every device your user have, check framework preferences file.
User avatar
bidulpik
Posts: 79
Joined: 17 November 2011, 09:02

Re: How to save user preference for my game in Cookies ?

Post by bidulpik »

Aaah, ok thank you both of you

I didnt know about local storage

https://developer.mozilla.org/fr/docs/W ... calStorage

i'll try it
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: How to save user preference for my game in Cookies ?

Post by Tisaac »

bidulpik wrote: 27 May 2021, 12:45 Aaah, ok thank you both of you

I didnt know about local storage

https://developer.mozilla.org/fr/docs/W ... calStorage

i'll try it
Do you want the preference to be saved accross devices ?
Because if that's the case, you need a user preference ! (check gameoptions.php in doc)
Post Reply

Return to “Developers”