Storing data with cookies
Cookies are little strings, which, once set for a domain and path, are sent over and over to the server for every request. This is perfect for authentication, but not so good if you're using them to store some data that you need only once or that you need to access only on the frontend, such as a player's score in a game whose results you are not storing on the server.
People usually use cookies to store heavy data to make it available on some other path on the domain. This is a bad practice because you're transferring that data to the server all the time, and, if that data is heavy, it'll make your communication slow.
Setting cookies
Let's take a look at how to access and set cookies using JavaScript:
Information found within a cookie is in the key=value;
 format. Let us create some cookies in the browser using the code snippet below:
document.cookie = "myFirstCookie=good;" document.cookie = "mySecondCookie=great;" console.log(document.cookie);
Warning: Strange behavior...