Skip to content

Items in cart disappear when closing and reopening browser #1097

Closed Answered by gmisa
gmisa asked this question in Help
Discussion options

You must be logged in to vote

I just realize that in session.server.ts, there is no maxAge property set. Because of that, session cookies only last 1 second thus making the cart items disappear when the browser is closed. By adding the maxAge property and setting it to 2 weeks (1209600 seconds), this issue doesn't happen anymore.

static async init(request: Request, secrets: string[]) { const storage = createCookieSessionStorage({ cookie: { name: 'session', httpOnly: true, path: '/', sameSite: 'lax', secrets, maxAge: 1209600, }, });

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@RohitDeshwal
Comment options

Answer selected by gmisa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants