Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set Cookie() function in JavaScript.

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 194
    Comment on it

    With the help of javascript i have created set Cookie() function. In the below code I have store all the values in the single cookie. By using this function many cookies will store at a time.

    <script type="text/javascript">
      var today = new Date();
      var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); 
    
      function setCookie(name, value)
      {
        document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
      }
    </script>
    

    The setCookie function is called by the form using the following function:-

    <script type="text/javascript">
    
      function storeValues(form)  
      {
        setCookie("field1", form.field1.value);
        setCookie("field2", form.field2.value);
        setCookie("field3", form.field3.value);
        setCookie("field4", form.field4.value);
        return true;
      }
    
    </script>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: