apunteak/ariketa-02/public/js/script.js
2022-01-29 20:56:40 +01:00

20 lines
542 B
JavaScript

function getCookie(name) {
var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return v ? v[2] : null;
}
var logged = document.getElementById('logged');
var unknown = document.getElementById('unknown');
if(document.cookie.includes("username")){
console.log(getCookie('username'));
logged.style.display= 'block';
unknown.style.display = 'none';
document.getElementsByTagName('h1')[0].innerHTML = "Kaixo " + getCookie('username') + "!!";
}else{
logged.style.display = 'none';
unknown.style.display = 'block';
}