[SOLVED] Trying to run the function getCookie() but its giving me a document is not defined error

Im trying to parse the following code on the root node of my game but it keeps throwing the same error. Should i run it on another node or what.

Hi @Granted,

Could you please provide an example of the code you’re having trouble with or a link to the project for other to take a look at?

1 Like

Oh yeah sorry
forgot to mention it works with my login script but not my network one. Also the script in the network works but when i parse it it gives an error but it does function properly in the game.

Hi @Granted,

I noticed you’re putting these functions in the global scope, instead of making them individual prototypes of each script:


I’m not sure this is the best idea, as every time you load a new script with the same function name, it will override any previous entries of it, and makes things rather difficult to troubleshoot. I’m not running into the error your describing during my initial tests. Can you please show exactly what the error is and the steps you took in order to reproduce it?

You may also want to consider foregoing using cookies in general. There are a lot of limitations on using them, in general, and I find that using localStorage is typically a much easier workflow, for me at least:

Of course you don’t have to change the way you’re saving this information, but it might be something to consider for the future.

1 Like

Oh shoot. I completely forgot about localStorage. I will swap to this instead. Thanks for the help

Ah yes, the classic parsing script issue. If you are calling or using window.document in global space, check if it’s null first and that will get around the issue.