I am trying to make a cookie that expires on a specific date. On w3schools they said to set it using
document.cookie="mediaType=Video; expires=Fri, 13 Mar 2015 12:00:00 UTC";
However in my code it doesn't seem to be working. What am I doing wrong?
<script>
var mediaType = "image";
function checkCookies(){
document.getElementById("div").innerHTML = document.cookie;
}
function getType() {
document.cookie="mediaType=Video; expires=Fri, 13 Mar 2015 12:00:00 UTC";
document.getElementById("div").innerHTML = document.cookie
}
</script>
<body onload="checkCookies()">
<select onChange="mediaType = this.value">
<option value="image">Image</option>
<option value="link">Link</option>
<option value="text">Text</option>
</select>
</body>
<div id="div" onclick="getType()"> hi</div>
BONUS is there a way to set a cookie as the value of a variable?