theodorejb / es-cookie

A simple, lightweight module for handling cookies
MIT License
45 stars 2 forks source link

Support expires values larger than the maximum date #11

Closed akh9804 closed 4 months ago

akh9804 commented 1 year ago

Expires should work even when it is above the maximum date

theodorejb commented 1 year ago

What is the use case for this? Can you show a code example where it would be useful?

akh9804 commented 1 year ago

Yes. I wanted to set expires as long as I can. So, I set it as a very large number.

Cookies.set('name', 'value', { expires: 100000000000 });

I expected cookies wouldn't expire almost forever but it did in short time.

It'd be very useful when you want cookies not to expire for a long time.

theodorejb commented 1 year ago

Why not set expires to a less insanely large number? E.g. even if you just set it to 100_000 that would be enough for the cookie to not expire for hundreds of years.

akh9804 commented 1 year ago

You're right. But I didn't know until I looked into source code that the error was due to the large value I put in. I think this one is necessary to prevent this situation.