_hyperscript icon indicating copy to clipboard operation
_hyperscript copied to clipboard

access cookie / localStorage

Open Zerotask opened this issue 2 years ago • 2 comments

I want to show a modal the first time a user logs in. Therefore I have a state in a cookie or localStorage, e. g. modalOpen which can either be missing or true and in these cases the modal should be shown. Afterwards it should set/update the cookie/localStorage, e. g. showModal=false

The specific action could be to add a css class (e. g. modal-open) or call an onclick modalId.showModal() (daisyUI)

Zerotask avatar Aug 21 '23 10:08 Zerotask

You can access localStorage as follows:

get localStorage.modalOpen
-- do stuff
set localStorage.modalOpen to value

dz4k avatar Aug 22 '23 07:08 dz4k

this saved me :) looks like this is not mentioned anywhere in the docs.

leandergangso avatar Aug 26 '23 00:08 leandergangso