-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set cookies? #578
Comments
We haven't developped anything about this currently. We discussed allowing information to be stored in the browser a few months ago. We have excluded writing cookies due to WF design. WF initiates the connection then the exchanges go through a websocket connection. a cookie cannot be written to the browser. The table in session is an image of cookies. To write a new cookie, the server need to answer an http request. There is none between the backend and the frontend. We discussed the possibility of writing to local storage. One possibility to be useful would be for the browser to send the content of local storage to the server during initialization and to be available in the Example of API def on_app_init(state, session):
state['user_settings']['bgcolor'] = session.local_storage.get('ui_settings', {}).get('bg_color', 'white')
def configure_ui_settings(state, payload, session):
ui_settings = session.local_storage['ui_settings']
ui_settings['bg_color'] = payload
state.set_local_storage('ui_settings', ui_settings) # accept only serializable type
def reset_ui_settings(state, session):
state.unset_local_storage('ui_settings')
# API
session.local_storage # dict with the content of wf_store from local_storage
session.set_local_storage # set a new value on localstorage
session.unset_local_storage # unset a key from localstorage |
really just having any way of storing data on the frontend would be very useful, cookies or local storage. could be used for a lot of things like storing models, settings, and session persistence / tokens / etc (things I want to do) |
Hi,
This framework is great (most ergonomic by far of the pure python ones I've tested), but I'm trying to find a way to modify cookies and store data locally on the client side. There doesn't seem to be a properly supported method of doing this currently?
I attempted to mutate the cookies in the session dictionary, but the changes were not propagated to the client side.
Is there any way to do this? Thanks.
The text was updated successfully, but these errors were encountered: