开发者

How do I save scores in my game using cookies?

I am currently making an Jeopardy game on the topic of开发者_StackOverflow社区 HTML using jQuery. Right now it works well, but I want to add a recent saved scores tag using cookies. I don't know how to achieve this.

I know cookies but I don't know how I will get the name and score and then save it.

I want to do something like this:

Recent Saved Scores

{NAME HERE}....{Score HERE}

{NAME HERE}....{Score HERE}

{NAME HERE}....{Score HERE}

And it's supposed to save.

Here's a link to my game: http://redirectme.yolasite.com/resources/jeopardy.html


I would suggest to use something like jstorage It uses localStorage or cookies if localStorage is not available.


Assuming that you know how to get/set cookie with javascript, just use json to encode the array of recent scores.

NOTE. cookies will register only results for the particular computer. if you need highscore chart, then you need some kind of backend e.g. php for storing and retrieving results.

let me know if you need any further guidance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜