Dart, creating cookies and reading them

1.1k views Asked by At

I want a way of saving progress/values on my web page so when some one exits and comes back onto the web pages they wont lose anything. Say money for instance. I am creating a game and they earn money but if they exit and come back they will be reset back to 0.

I thought maybe cookies would be a good idea to save the values of variables? Also when they return to the web page it would need to detect the cookies and receive the values and set the variables accordantly.

how would I go about doing this, or is there an easier/better way?

2

There are 2 answers

5
Greg Lowe On BEST ANSWER

Cookies can't hold much information. Sounds like you want to store more.

First have a look at local storage - sample here.

Or you can consider using lawndart which is an api built on top of indexeddb and websql (for Safari). Here is a tutorial about indexed db.

0
Günter Zöchbauer On

polymer_elements for Dart offers this functionality too

  • polymer_cookie

or

  • polymer_localstorage