I'm not familiar with cookies, but I would do it with localStorage instead. It's easier, but also more appropriate for this use case.
Something like this:
localStorage.setItem('currentLevel', 1);
var level = localStorage.getItem('currentLevel');
Wow! Thank you very much. This is an answer I wanted to find! Thank you. Appreciate your help!