I'm trying to create and store cookie data from an html file using javascript. The first function creates a cookie, and the second is meant to store it.
When the function is called, the console correctly logs the desired information, but the cookie doesn't seem to be created.
JS:
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + "; " + expires + "; path=/";
console.log('Cookie created as ' + name + "=" + value + ". Expiration: " + expires);
}
function readCookie(name) {
var x = retrieveCookie(name);
if (x) {
window.alert(x);
console.log('Cookie passed to alert menu')
}
else {
console.log('Cookie was undefined and did not return');
}
}