Cookie mit Fenster begrüßt Besucher



Hier sehen Sie nicht. Achten Sie oben auf die Tafel

Quellcode
<html>
<head>

<style type="text/css">Hier nichts</style>
</head>

<body onload="checkCookie()">
<script>
function setCookie(cname,cvalue,exdays) { const d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); let expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";}
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i++) { let c = ca[i];
while (c.charAt(0) == ' ') { c = c.substring(1); }
if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } }
return "";}
function checkCookie() {
let user = getCookie("username");
if (user != "") { alert("Hallo "+ user + ". Schön, daß du wieder da bist! " ); }
else { user = prompt("Bitte gebe deinen Namen ein:","");
if (user != "" && user != null) { setCookie("username", user, 30); } } }
</script>
</body>

</html>








Kontakt    Datenschutz    Impressum