30 मिनट की एक्सपायरी
आप एक्सपिरेशन डेट सेट करके और कुकी के भीतर एक्सपायरी डेट सहेजकर कुकी के जीवन को वर्तमान ब्राउज़र सत्र से आगे बढ़ा सकते हैं। यह 'expires' एट्रिब्यूट को डेट और टाइम पर सेट करके किया जा सकता है।
उदाहरण
<html>
<head>
<script>
<!--
function WriteCookie() {
var now = new Date();
var minutes = 30;
now.setTime(now.getTime() + (minutes * 60 * 1000));
cookievalue = escape(document.myform.customer.value) + ";"
document.cookie="name=" + cookievalue;
document.cookie = "expires=" + now.toUTCString() + ";";
document.write ("Setting Cookies : " + "name=" + cookievalue );
}
//-->
</script>
</head>
<body>
<form name="myform" action="">
Enter name: <input type="text" name="customer"/>
<input type="button" value="Set Cookie" onclick="WriteCookie()"/>
</form>
</body>
</html>