utils.js: set Secure flag on cookies if using HTTPS

Related to https://gitlab.com/commento/commento-ce/issues/79
This commit is contained in:
Adhityaa Chandrasekar 2018-09-23 01:09:59 -04:00
parent 2a713c22f1
commit 405d10766a

View File

@ -71,7 +71,11 @@
date.setTime(date.getTime() + (365*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
document.cookie = name + "=" + value + expires + "; path=/";
var cookieString = name + "=" + value + expires + "; path=/";
if (/^https:\/\//i.test(commentoOrigin))
cookieString += "; secure";
document.cookie = cookieString;
}