I have problems to save a cookie in javascript

0

My problem is that I try to create a cookie to know which is the user that is using the web, the system I want to try is quite simple, I just want to create the cookie from the mail of the person who wants to start the session, the cookie should be created even if the email is incorrect - This does not matter since the web does not have sensitive information and the login form will not let the user enter if it provides the incorrect data -.

But it turns out that for some reason javascript does not add the cookie, can you help me?

<script>

  var identiu = function(){     
        document.cookie = "identi=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/127.0.0.1";
        var name = identi;
        var value = document.getElementById("emailusuario");
       document.cookie = name + "=" + value + ";path=/127.0.0.1";
   }
    </script>
    
asked by HatCliff 09.04.2017 в 00:28
source

1 answer

0

Try this way:

<script>

  var identiu = function(){     
        document.cookie = "identi=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
        var name = identi;
        var value = document.getElementById("emailusuario");
       document.cookie = name + "=" + value + "; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
   }
</script>

Also, as you are told, never try to create the cookies from the client, try to do it from the same PHP.

    
answered by 09.04.2017 / 05:29
source