Ask coding questions

← Back to all posts
JacobMcPherson1 (191)

How do i save game progress with cookies?

Coder100 (16853)

I would more recommend localStorage, so much easier to use, and you don't have to worry about expiration.

localStorage.setItem("<key>", "<value>");

just like that! That's it! The value has to be a string, however.

localStorage.setItem("cookies", "0");

and then to get a kei:


Number() just converts it into a number, which is useful for us.

JacobMcPherson1 (191)

@Coder100 so I just put both those lines in and it'll save your cookie amount?

SameeraMurthy (110)


In JavaScript, you can create cookies with document.cookie.

document.cookie = "score=10";

But if you want to use more features out of
cookies, check out

It also gives you some code to create a wrapper function for setting and getting cookies.

You can also save info with localStorage.