Project

General

Profile

Access browser window localStorage?

Added by Rakesh Vidyadharan 5 months ago

Hello,

Is there any way to access browser localStorage? I would like to try and use that for storing some local state on the client without having to using cookies.

Thanks
Rakesh


Replies (2)

RE: Access browser window localStorage? - Added by Matthias Van Ceulebroeck 5 months ago

Hello Rakesh,

there is no functionality in Wt that wraps access to the local or session storage of the browser. You can just write doJavaScript, and then any getter / setter to change its values. If you want to use the values in there in your backend code, you will need to set up a JSignal, that will be fired on getting/setting an item on the storage. You can do this by overriding the getter of setter of the storage.

Best regards,
Matthias

RE: Access browser window localStorage? - Added by Rakesh Vidyadharan 5 months ago

Thanks for the pointers Matthias, I will try it out.

    (1-2/2)