Skip to content
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

[storage] cookieStorage's maxAge option doesn't work #530

Open
yume-chan opened this issue Oct 20, 2023 · 3 comments · May be fixed by #625
Open

[storage] cookieStorage's maxAge option doesn't work #530

yume-chan opened this issue Oct 20, 2023 · 3 comments · May be fixed by #625

Comments

@yume-chan
Copy link

Describe the bug

Create a persisted signal using cookieStorage and passing the maxAge option, but the created cookie is a session cookie.

In the linked StackBlitz project, click "Open in New Tab" button at top-right corner. Looks like it can't set cookies from an iframe.

  const [maxAge, setMaxAge] = makePersisted(createSignal('initial'), {
    name: 'maxAge',
    storage: cookieStorage,
    storageOptions: { path: '/', maxAge: 60 * 60 * 24 * 7 },
  });
  const [expires, setExpires] = makePersisted(createSignal('initial'), {
    name: 'expires',
    storage: cookieStorage,
    storageOptions: {
      path: '/',
      expires: new Date(Date.now() + 60 * 60 * 24 * 7 * 1000),
    },
  });

  createEffect(() => {
    setMaxAge('hello');
    setExpires('hello');
  });

image

Minimal Reproduction Link

https://stackblitz.com/edit/github-n4ho5j-nffe5j?file=src%2Froutes%2Findex.tsx

@sh1man999
Copy link

I confirm this error

@apatrida
Copy link

apatrida commented Apr 29, 2024

The problem is serializeCookieOptions doesn't convert maxAge to max-age

@atk
Copy link
Member

atk commented Apr 29, 2024

Thanks, will fix.

@atk atk linked a pull request Apr 29, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants