madmurphy / cookies.js

Simple cookie framework with full Unicode support
GNU General Public License v3.0
265 stars 54 forks source link

Compatibilitie problem with Internet Explorer (all versions) and the use of max-age. #5

Closed lcrespilho closed 7 years ago

lcrespilho commented 7 years ago

On setItem method, the use of max-age isn't compatible with any version of Internet Explorer, Edge and a lot of Mobile browsers (as sugested by MDN Document.cookie).

Maybe you could alter line 37 with something like this: sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; expires=" + new Date(new Date().getTime() + vEnd).toUTCString(); that has full browser support.

Thanks a lot. Best regards.

madmurphy commented 7 years ago

@lcrespilho

Thanx for opening this issue!

This library aims to abstract JavaScript's access to cookies, but does not aim to help good standards to become deprecated. The max-age parameter is a good parameter and is a standard defined in rfc6265. Nevertheless the lack of support in some browsers, as your comment attests, cannot be ignored.

After thinking a bit, I decided, instead of removing the library's internal usage of max-age, to explain the current situation and offer an easy solution in a note in the MDN article – which is the official documentation page of this library.

All the best!

lcrespilho commented 7 years ago

@madmurphy Thanks for your feedback. I just saw the note on MDN article and your argument sounds fair.

Thanks a lot. Regards.