JavaScript Program to Create a Persistent Cookie

Write a JavaScript program to create a persistent cookie.

Source Code
    <title>Persistent Cookie Example</title>
        function WriteCookie()
            var expireDate = new Date();
            expireDate.setMonth(expireDate.getMonth() + 1);

            with (document.CookieWriter)
                document.cookie = "ItemName=" + "; expires=" + expireDate.toGMTString() + ";";
                alert("Cookie Written");
<form name="CookieWriter" action="" >
    Enter the item name:<input type="text" name="customer" onchange="WriteCookie()"/>

"Coding Hub - Learn to code" app now available on Google Play Store