Sorry but I don't believe this is possible in Retool. Global functions in Retool mean that they are available in all your apps, but still can't reach outside of the JS sandbox.
We do however have an internal localStorage API that interacts with the browser's local storage. You can learn more about that here.
After some digging I'm able to confirm that this is a known bug/issue the team's aware of and currently isn't possible. The feature request however has been put in