Skip to content

maxAge should be in seconds #7

@zmb3

Description

@zmb3

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions