I\'m trying to set multiple cookies in document.cookie
, but unfortunately only one is getting added.
I know there are multiple examples present on the \'Net
Adding a cookie is performed via document.cookie = "name=value"
to add multiple keys, you should perform multiple assigments
function setCookie(start_time, end_session_time, total_time, flag, count) {
document.cookie = "start_time=" + start_time;
if (end_session_time) {
document.cookie = "end_session_time=" + end_session_time;
}
if (total_time) {
document.cookie = "total_time=" + total_time;
}
if (flag) {
document.cookie = "flag=" + flag;
}
if (count) {
document.cookie = "count=" + count;
}
console.log("document.cookie = " + document.cookie);
}