I’ve created a cookie like below and can retrieve all font_size, back_color and font_name. But once I close the browser the cookie is lost. From what I know is if we get expiry date wrong cookie can be lost but I’ve tested the date, expireGMT and is fine. Have I done anything wrong in the code below? Do I need to include path as well?
document.cookie = "font_size=14";
document.cookie = "back_color=Gray";
document.cookie = "font_name=Georgia";
document.cookie = "expires=" + expireGMT;
Each individual write to
document.cookieis the setting of a cookie, and any options (including that cookie’s expiration date) must be set on that write. You need to include the expiring time on every cookie assignment:without that, each cookie will be created as session cookies and expire when the browser’s closed.