I had to declare the cookie a variable to use it, the way i made it is inefficient but a quick solution.
<p id="motherhome">
Cookie test
</p>
<button onclick="creation()">
Create
</button>
<button onclick="ragnarok()">
Delete
</button>
<button onclick="showhw()">
Display
</button>
<p id="pancreas">no cookie hahah</p>
<script>
function creation(){
document.cookie = "username=John Doe; expires=Thu, 18 Dec 2021 12:00:00 UTC; path=/lostch1.html";
}
function ragnarok(){
document.cookie = "username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC; path=/lostch1.html";
}
function showhw(){
document.getElementById("pancreas").innerHTML = username;
}
var username = document.cookie;
</script>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…