kristianhristov / cordova-cookie-master

MIT License
26 stars 113 forks source link

How to set expiry time while setting the cookie #20

Open shrivallabhDeshmukh opened 5 years ago

shrivallabhDeshmukh commented 5 years ago

I need to set cookie expiration time . Please help

boralp commented 5 years ago

Sadly there is no implementation of expiration date on this project.

foumart commented 3 years ago

It took me some time to figure it out (less than two years though :). Here is how to set expiry time:

let cookieName = 'my_cookie_name';
let cookieValue = 1;
let expirySeconds = 86400; // 1 day = 60*60*24

cookieMaster.setCookieValue(URL, cookieName, `${cookieValue}; max-age=${expirySeconds};`);