BCJTI / ng2-cookies

Simple library to deal with cookies in Angular2
64 stars 31 forks source link

Use a Date object on Cookie.set() #24

Closed possatti closed 8 years ago

possatti commented 8 years ago

Hey guys. This is only a suggestion.

I needed to use Cookies in my app so I looked for something on npm. At first a came to this repo, but in my app I need to set the Cookie expiration to a precise date and time (even seconds). And then I realized this package only allows for setting the expiration using a delta set in days. And this prevented me from using this repo.

Currently I have implemented what I needed using angular2-cookie. But I just wanted to leave the suggestion for you guys that you allow for setting the expiration date using a Date object, with seconds precision.

Bigous commented 8 years ago

Good point.

We could just do the math to achieve the delta from the specific date.

Tyxz commented 8 years ago

This should do the trick. Did not test it in a live version, but with simple browser debuging it works