Setting cookies with form input

I am trying to make a username cookie using the users input to a web form.However
its not working and I don;t know why. do you know what the problem is?

    <input type="text" value="Enter Your Nickname" id="nameBox">
    <input type="button" value="Go!" id="submit" onClick="putCookie">

    var today = new Date();
    var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days

    function setCookie(name, value){
        document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
    //this should set the UserName cookie to the proper value;
    function storeValues(form){
        setCookie("userName", form.submit.value);
        return true;


Source: forms

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.