Reputation: 1
Please i tried to create a cookie from javascript code and set its name = fullname, value = id and expires in one hour but when i checked my browser(chrome) i found that it not exists, so any idea about my code issues
function cookie_set(fullname, id) {
var now = new Date();
now.setTime(now.getTime() + 1 * 3600 * 1000);
//document.cookie = "name=" + fullname + "=" + id;
document.cookie = fullname + "=" + id + "; expires=" + now.toUTCString + "; path=/";
}
Upvotes: 0
Views: 28
Reputation: 1313
You've got an bug in your code:
document.cookie = fullname + "=" + id + "; expires=" + now.toUTCString() + "; path=/";
Upvotes: 1