Search code examples
javascriptcookies

Maximum LifeTime of javascript cookie


What can be the maximum acceptable expiry-time value of Javascript persistence cookie?


Solution

  • Read : Expires and Max-Age of Cookies

    Life time of the javascript cookies is depend on what amount of time you set when creating cookies for example following set the life time of 10 minutes

    expiry = new Date();   
    expiry.setTime(date.getTime()+(10*60*1000)); 
    // Ten minutes   
     // Date()'s toGMTSting() method will format the date correctly for a cookie   
    document.cookie = "visited=yes; expires=" + expiry.toGMTString(); 
    

    there is no way that you can set the life time coookie...i.e cookie with no expiration