React Cookie + ReactJS: How to set expiration time for a cookie?
In my ReactJS project, currently I am saving the cookie like cookie.save('token', received_token, { path: '/'} ); and retrieving it from the local storage like so: cookie.load('token'); . So I was wondering, is a way to set expiration time when .save() the token received, and once expired, automatically have it remove itself from the local storage? Thank you and will accept the answer with vote up. You can pass maxAge or expires in options as 3rd parameter in cookie.save function Syntax: reactCookie.save(name, val, [opt]) Example: // maxAge Example reactCookie.save("token", "token-value", {