Create Cookie



Write a javascript code to create a cookie.


<html>            
  <head>
    <script>
      
      function CreateCookie() 
      {
          var cookie_value = username.value;

          document.cookie = "username=" + cookie_value;

          alert("Cookie is created");
      }
  
    </script>
  </head>
<body>
  
   Enter Username: <input type='text' id='username'>
  
  <input type='button' value='Create Cookie' onclick='CreateCookie()'>
  
  </body>
</html>

Output: