I went through solution which Lukas told me about (instead of retrieving variable from local storage), and, of course, it was successful. Solution was very easy: I just created new non persistable entity and everything was solved. :)
Lukas, thank you very much for instructions.
Your request seems a bit un-mendix to me. Can't you create a non persistent entity that is associated to the session entity instead of writing and reading the local storage? The HTML snippet does provide an optional on-click microflow event that might help you out here.
Nanoflows are run locally on client, so this might be an alternative, however still, you need to read the local storage through a widget.
There is a widget that you can use for reading and writing to local storage: https://appstore.home.mendix.com/link/app/52055/.
Perhaps this helps.