Skip to content

clearCookie does not include maxAge, neither allows to pass it as options #303

@aristofun

Description

@aristofun

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.0

Plugin version

v10.0.1

Node.js version

any

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

any

Description

These are the problematic lines:

fastify-cookie/plugin.js

Lines 42 to 46 in ccb9053

const opts = Object.assign({ path: '/' }, options, {
expires: new Date(1),
signed: undefined,
maxAge: undefined
})

Without maxAge: 0 at least some of cookie jar implementations (for example https://www.npmjs.com/package/tough-cookie) keep actual cookie with empty value in the storage instead of deleting them (like they do when maxAge is set to zero).

Because of this flaw some users had to come up with workarounds like this.

Link to code that reproduces the bug

No response

Expected Behavior

maxAge should be set along with expires option

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions