Set the cookie expire date
<html> <head> <title>Hello Cookie</title> <script type = "text/javascript"> var cookName = "cookie1"; var cookVal = "testvalue"; var date = new Date(); date.setTime(date.getTime()+86400000); var expireDate = date.toGMTString(); var myCookie = cookName + "=" + cookVal + ";expires=" + expireDate; document.cookie = myCookie; </script> </head> <body> <p>Hello</p> </body> </html>