Add helper method for deleting typed cookies #213
Closed
mikeybinns
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
I would suggest to add this directly to Remix so there's a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Because values passed into
.serialize()
are type-checked, it's really annoying to delete cookies. You must first parse the set cookie, making sure it's valid just to pass it back to delete the cookie, and if it's invalid (say you pass something like{} as NonNullable<Awaited<ReturnType<typeof myCookie.parse>>>
like I tried) then it prevents you from deleting the cookie.I suggest adding a helper method called delete that takes no parameters and essentially skips the serialize typechecking steps, sets
null
as the value and sets the expires tonew Date(1970, 0, 1)
.Example usage:
Search terms:
delete cookie
Beta Was this translation helpful? Give feedback.
All reactions