30 lines
897 B
JavaScript
30 lines
897 B
JavaScript
function remeberMe(){
|
|
let input = document.getElementById("username");
|
|
let username = input.value;
|
|
document.cookie = "username=" + username;
|
|
console.log("Thank you "+ username);
|
|
}
|
|
|
|
function forgetMe(){
|
|
document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"
|
|
console.log("Poof!...");
|
|
}
|
|
|
|
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 "";
|
|
}
|
|
|
|
let decodedCookie = getCookie("username") + " ";
|
|
document.getElementById("introtitle").textContent = "Welcome " + decodedCookie + "to the Void System" |