aslauris
WWasp-lang
•Created by aslauris on 4/26/2024 in #🙋questions
Storing additional data in session
Sweet ❤️
14 replies
WWasp-lang
•Created by aslauris on 4/26/2024 in #🙋questions
Storing additional data in session
Sure thing @sodic !
14 replies
WWasp-lang
•Created by aslauris on 4/26/2024 in #🙋questions
Storing additional data in session
Hi @sodic thanks for getting back! To be honest, I've never checked how it's done under the hood (until now) as it comes with a convenient API and just works 🙂 Blitz provides the following APIs:
-
ctx.session.$setPublicData()
or setPublicDataForUser()
to set public session data in the server side
- it persists data in the DB sessions table as a json object and also sends back the updated public data in the response cookie as a base64
token which is persisted in both cookies and local storage
- public session data could be accessed via useSession()
in the front-end and e.g. ctx.session.orgId
in the back-end
I found it really helpful in some use cases (user roles, multiple orgs per user, etc.). Of course, it's not a show stopper for me as I can implement some alternative myself but it might be a nice addon to WASP. I hope you'll find this useful too. I'm new to WASP but so far so good, nice work guys! 😉14 replies