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

maxAge should be in seconds #7

Open
zmb3 opened this issue Jan 26, 2021 · 0 comments
Open

maxAge should be in seconds #7

zmb3 opened this issue Jan 26, 2021 · 0 comments

Comments

@zmb3
Copy link

zmb3 commented Jan 26, 2021

A cookie's Max-Age is the number of seconds until expiration, so the following code doesn't do what the author intended.

  const hour = 3600000
  const twoWeeks = 14 * 24 * hour
  const myCookie = cookie.serialize('my_cookie', 'lolHi', {
    secure: true,
    httpOnly: true,
    path: '/',
    maxAge: twoWeeks,
  })

An hour is 60*60=3600 seconds, it looks like this code is treating the max age as milliseconds.

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

No branches or pull requests

1 participant