I was looking for more knowledge about cookies on youtube and only found video in English, but what does this have more? I do not speak English! However, I understood that cookies work this way → are stored, read and sometimes deleted.
Where do I want to go? Well ... I want to put cookies in 2 scripts, but so far I can not. I had asked here in the forum how to put cookies in this script ↓↓↓
<a id="id1" href="https://br.answers.yahoo.com" onclick="myFunction(event)" target="_blank">Clique Aqui</a> <br/><br/>
<script language="javascript">
function myFunction(s) {
var id = s.target.id;
document.getElementById(id).style.color = "green";
setTimeout(function(){
document.getElementById(id).style.color = "blue";
}, 10000);
}
</script>
So I got this answer: ↓
If you want it to continue indefinitely until you delete it, you can do this with html5, or if you want to forget the data when closing the browser as well.
INDEFINIDAMENTE: // Armazenar
localStorage.setItem("lastname", "Smith");
// Receber
var lastname = localStorage.getItem("lastname");
// Remover
localStorage.removeItem("lastname");
TEMPORARIAMENTE // Armazenar
sessionStorage.setItem("lastname", "Smith");
// Receber
var lastname = sessionStorage.getItem("lastname");
// Remover
sessionStorage.removeItem("lastname");
But I did not understand how to insert, can you help me?