Closed chz closed 6 days ago
If you trust the sockets, just use a ref() on client-side it should be enough, like unreadNotifications = ref(0)
.
@atinux no i mean we have salted and hashed cookie where user object inside it. how can o update it?
@atinux no i mean we have salted and hashed cookie where user object inside it. how can o update it?
You must update using a server endpoint. A session is, for the client, a black box and this is by design. Imagine all the potential security issues if you were able to change data inside your session without by yourself, without asking a server (that will verified everything).
On your client, you can re-fetch (const { fetch } = useUserSession(event)
) to retrieve new session data.
@atinux no i mean we have salted and hashed cookie where user object inside it. how can o update it?
You must update using a server endpoint. A session is, for the client, a black box and this is by design. Imagine all the potential security issues if you were able to change data inside your session without by yourself, without asking a server (that will verified everything).
On your client, you can re-fetch (
const { fetch } = useUserSession(event)
) to retrieve new session data.
I know this. But i want update only user.[key] in client side.Best option save user data to state?
You can make a copy of the user
into another ref() if you want @chz
You can make a copy of the
user
into another ref() if you want @chz
Thank you.
Hi @atinux. Thanks for amazing work on it!
I need help. How can i update session.user object on client side? Lat say i have socket and i need update unread key inside user object from socket data.unread. or i must call server route and update it in serverside? every time when i get socket updates?
await setUserSession(event, {...})
must be used in server side and need event.