-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add session package #10822
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
Add session package #10822
Conversation
09ba3d0 to
a28d440
Compare
brophdawg11
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I like the cleaner decoupling of the cookie/session and the new storage APIs of update/delete instead of commitSession/destroySession 👍
Also, sessions must now be "started" by using the session() middleware before they can be used.
| get size(): number { | ||
| return this.#valueMap.size + this.#flashMap.size | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we end up using this for anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, I ended up adding a context.sessionStarted flag instead and issuing a warning if someone starts using context.session without a session() middleware in the stack since it's a no-op. I still think session.size is a nice-to-have though, so I left it in.
This PR adds a new
@remix-run/sessionpackage and asessionmiddleware tofetch-router.It's a complete rewrite of the session handling code we currently have in Remix v2 and RR v7. The main motivations for this work were:
session.flash()valuesFileSessionStoragefor storing sessions on the filesystemThis PR closes #10790 and #10794, and supersedes #10811