From 405d10766a0bcf791a23dc01614627031f94c9f9 Mon Sep 17 00:00:00 2001 From: Adhityaa Chandrasekar Date: Sun, 23 Sep 2018 01:09:59 -0400 Subject: [PATCH] utils.js: set Secure flag on cookies if using HTTPS Related to https://gitlab.com/commento/commento-ce/issues/79 --- frontend/js/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/js/utils.js b/frontend/js/utils.js index 849dec8..06fd694 100644 --- a/frontend/js/utils.js +++ b/frontend/js/utils.js @@ -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; }