1
I have following code:
In the archive cookieSimplescont2.js:
function criarCookie(valorCookie){
 //Criar objeto data
 var data = new Date();
 // setando o tempo de vida do cookie
 data.setTime(data.getTime()+120000);
 //Criando a estrutura do Cookie
 document.cookie = "primeiroCookie="+valorCookie+" ; expires="+data.toUTCString()+" ; path=/";
 return "Sucesso";
}
function lendoCookie(){
    return document.cookie;
}<!DOCTYPE html>
<html>
<head>
    <title>Cookies</title>
    <meta charset="utf-8">
    <link rel="stylesheet" type="text/css" href="css/estilo.css">
    <script type="text/javascript" src="js/cookieSimplescont2.js"></script>
</head>
<body>
<h1>HTML SO PARA TESTES--- Testando Cookies</h1>
 <button onclick="alert(criarCookie('DiaBonito'))">Criar Cookie</button>
 <button onclick="alert(lendoCookie())">Lendo Cookie</button>
</body>
</html>Well, for the job LendoCookie() work before I have to click on Cookie but only because I set a spiraling time of the cookie 2 minutes short, the funçãoLendoCookie() returns the key of cookie when I open the file cookieSimplescont2.html using IE or Firefox, but not Chrome. I already went to Chrome’s cookie settings and in the privacy field I chose "Allow local data configuration (recommended)." but even then does not return any value, someone can tell me why ?
Are you using a web server? type wamp or xampp?
– Asura Khan
@Guilherme Nascimento no
– Mandy
@Mandy then cookies will not work as I explained here https://answall.com/a/182596/3635
– Guilherme Nascimento