-
-
Notifications
You must be signed in to change notification settings - Fork 252
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
v8 beta release, last tasks and discussions #620
Comments
cc @devjmetivier as for the OverridableOptions question. Thanks. |
These aren't required in the next.js example because we are passing
then cookies are appended to the original If we aren't planning on supporting other frameworks, then I guess it's fine to not export them. |
iron-session v8 is live now 👍 https://github.com/vvo/iron-session |
Hey. I see this is closed now, however, for the use case of Overridable Options is that: We can set our options for our Iron Session object during
const getServerActionSession = async () => {
const session = getServerActionIronSession<IronSessionData>(sessionOptions, cookies())
return session
}
export const submitCookieToStorageServerAction = async (cookie: string) => {
const session = await getServerActionSession()
session.cookieVariable = cookie
const newCookieOption = { cookieOptions: { maxAge: undefined } }
await session.save(newCookieOption)
} We need const defaultOptions: Required<OverridableOptions> = {
ttl: fourteenDaysInSeconds,
cookieOptions: { httpOnly: true, secure: true, sameSite: 'lax', path: '/' },
} function mergeOptions(
userSessionOptions: IronSessionOptions,
overrides?: OverridableOptions,
): Required<IronSessionOptions> {
const options: Required<IronSessionOptions> = {
...defaultOptions,
...userSessionOptions,
...overrides,
cookieOptions: {
...defaultOptions.cookieOptions,
...userSessionOptions.cookieOptions,
...overrides?.cookieOptions,
},
}; We need the type OverridableOptions = Pick<IronSessionOptions, "cookieOptions" | "ttl">; The final type definition for `CookieOptions` ends up to be
`'domain' | 'path' | 'secure' | 'sameSite' | 'name' | 'value' | 'expires' | 'httpOnly' | 'maxAge' | 'priority'` Note these code examples refer to the codebase before the most recent Friday release changes. Congratulations on the release! |
Thank you @renchris, for the detailed explanation. What I have done in the end: I created updateConfig that you can call anytime to update any options: Line 115 in eb1db40
This should be enough, correct? |
Also @renchris I mentioned you here: https://twitter.com/vvoyer/status/1726521507457986758 👍 |
Hi there, @brc-dd and @renchris. First, thank you for all your contributions and help and everyone who chimed in on #586.
Here's the status: I published
[email protected]
, please give it a try:Usage: https://github.com/vvo/iron-session/tree/v8#usage
Notable changes and questions to finish this release:
getIronSession(req, res, sessionOptions)
andgetIronSession(cookieStore, sessionOptions
OverridableOptions
? I don't understand the usecase yet, please be specific 🙏pnpm dev
at the root of the repoThank you again, looking forward to discussing here now and reach a shippable state super soon.
The text was updated successfully, but these errors were encountered: