एकाधिक पृष्ठों के लिए कुकीज़ सेट करने के लिए, आपको पथ को -
के रूप में सेट करना होगा;path=/
उदाहरण
उपरोक्त आपके कुकीज़ को साइट कुकी बना देगा। आप एकाधिक पृष्ठों के लिए कुकी सेट करने के लिए निम्न कोड चलाने का प्रयास कर सकते हैं -
लाइव डेमो
<html>
<head>
<script>
<!--
function WriteCookie() {
if( document.myform.customer.value == "" ) {
alert("Enter some value!");
return;
}
cookievalue = escape(document.myform.customer.value) + ";";
document.cookie = "name=" + cookievalue + "; path=/";
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>