-
-
Notifications
You must be signed in to change notification settings - Fork 562
Closed
mswjs/cookies
#6Description
Hi there, am trying to figure how to clear/expire/delete a cookie - if this is possible? I have three pretty simple endpoints mocking a session, when you post in some credentials, it sets a cookie:
return res(
ctx.cookie("auth-token", "random-string"),
ctx.json({ authenticated: true })
)
when you get the session, it checks the cookie is there
return res(
ctx.json({ authenticated: req.cookies["auth-token"] !== undefined })
)
and when you delete a session, it sets the expiry to the past:
const expires = new Date(moment().subtract(1, "second").toDate())
return res(
ctx.cookie("auth-token", undefined, { expires })
ctx.json({ authenticated: false })
)
the issue I'm seeing is, after deleting a session, even though the browser has cleared off the expired cookie, req.cookies("auth-token")
still retains the old value on subsequent requests
Metadata
Metadata
Assignees
Labels
No labels