How to create a session only cookies with JavaScript?


To create a session only cookie, you need to set the expiration date of the cookie to be some years ahead. You need to set the expire attribute:

current time + 5 years

The expire attribute shows the date the cookie will expire. If this is blank, the cookie will expire when the visitor quits the browser.

Note: Do not consider removing the expire value to create a session only cookie. This won’t work. Set the expire attribute to the future date.

raja
Published on 31-Jan-2018 12:28:54
Advertisements