You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that deleting or not saving expired cookies from the file is normal behavior. But sometimes some sites return tokens in the cookie that, despite the expiration of the cookie date and removal from the browser, that token is still valid in subsequent requests and there is no need to request again to get that token. So I don't need that cookie to be deleted.
I have to solve this problem.
I did a review and found that my previous problem was not related to keeping expired cookies. It means that the cookies whose expiration date has reached should be deleted in any case.
The problem was related to the time when the expiration date was not set for the cookie, which caused the cookie not to be saved.
That is, for example, in cases where the site returns the cookie like this:
Because the expiration date is null, this cookie is assumed to be expired and will never be saved. While browsers accept it and set a standard value like this:
Expires / Max-Age: "Session"
So as a quick fix I solved the problem with a small change in the cookiesValid function, for which I am sending a PR.
NabiKAZ
changed the title
It is not always necessary to delete expired cookies
Cookies without an expiration date should also be retained
Feb 8, 2024
Thanks for your nice project.
I understand that deleting or not saving expired cookies from the file is normal behavior. But sometimes some sites return tokens in the cookie that, despite the expiration of the cookie date and removal from the browser, that token is still valid in subsequent requests and there is no need to request again to get that token. So I don't need that cookie to be deleted.
I have to solve this problem.
node-fetch-cookies/src/cookie-jar.mjs
Lines 108 to 109 in db40f03
This code:
this.cookiesValid(false)
to this:
this.cookiesValid(true)
I changed.
It might be a good idea to add a parameter to the main class to select and manage this feature.
The text was updated successfully, but these errors were encountered: