Update the cookies associated with the document in JavaScript
Description
The following code shows how to update the cookies associated with the document.
Example
<!--from w w w. ja v a2 s . co m-->
<!DOCTYPE HTML>
<html>
<body>
<script>
var cookieCount = 0;
//read Cookies
document.writeln(document.cookie);
//create Cookie
cookieCount++;
document.cookie = "Cookie_" + cookieCount + "=Value_" + cookieCount;
//read Cookies
document.writeln(document.cookie);
//update Cookie
document.cookie = "Cookie_" + cookieCount + "=Updated_" + cookieCount;
//read Cookies
document.writeln(document.cookie);
</script>
</body>
</html>
The code above generates the following result.
Javascript Tutorial Cookie
Add date type value as cookie value in Java...
Read cookie by name in JavaScript
Read cookie value and fill the value to for...
Read value from a input text field and use ...
Set cookie with additional items separated ...
Set the cookies associated with the documen...
Add date type value as cookie value in Java...
Read cookie by name in JavaScript
Read cookie value and fill the value to for...
Read value from a input text field and use ...
Set cookie with additional items separated ...
Set the cookies associated with the documen...