Use different cookie name for different protocols - https://github.com/ether/etherpad-lite/issues/3179

pull/3187/head
Mikk Andresen 2017-05-05 10:28:44 +03:00
parent b43137ad2c
commit 96cc1ad55a
1 changed files with 4 additions and 2 deletions

View File

@ -23,6 +23,8 @@
var padcookie = (function()
{
var cookieName = isHttpsScheme() ? "prefs" : "prefsHttp";
function getRawCookie()
{
// returns null if can't get cookie text
@ -31,7 +33,7 @@ var padcookie = (function()
return null;
}
// look for (start of string OR semicolon) followed by whitespace followed by prefs=(something);
var regexResult = document.cookie.match(/(?:^|;)\s*prefs=([^;]*)(?:;|$)/);
var regexResult = document.cookie.match(new RegExp("(?:^|;)\s*" + cookieName + "=([^;]*)(?:;|$)"));
if ((!regexResult) || (!regexResult[1]))
{
return null;
@ -44,7 +46,7 @@ var padcookie = (function()
var expiresDate = new Date();
expiresDate.setFullYear(3000);
var secure = isHttpsScheme() ? ";secure" : "";
document.cookie = ('prefs=' + safeText + ';expires=' + expiresDate.toGMTString() + secure);
document.cookie = (cookieName + "=" + safeText + ";expires=" + expiresDate.toGMTString() + secure);
}
function parseCookie(text)