Set cookies on the client side as secure and safe to set as third party if possible

This commit is contained in:
Fedor A. Fetisov 2021-08-24 17:22:52 +03:00 committed by Fedor A. Fetisov
parent 098abccde7
commit 423ef8d36f

View File

@ -57,11 +57,14 @@ var Mibew = Mibew || {};
* omitted a session cookie will be created. * omitted a session cookie will be created.
*/ */
Mibew.Utils.createCookie = function(name, value, expires) { Mibew.Utils.createCookie = function(name, value, expires) {
var domain = /([^\.]+\.[^\.]+)$/.exec(document.location.hostname); if (navigator.cookieEnabled) {
document.cookie = "" + name + "=" + value + "; " var domain = /([^\.]+\.[^\.]+)$/.exec(document.location.hostname);
+ "path=/; " document.cookie = "" + name + "=" + value + "; "
+ (domain ? ("domain=" + domain[1] + "; ") : '') + "path=/; "
+ (expires ? ('expires=' + expires.toUTCString() + '; ') : ''); + (document.location.protocol == 'https:' ? "SameSite=None; secure; " : '')
+ (domain ? ("domain=" + domain[1] + "; ") : '')
+ (expires ? ('expires=' + expires.toUTCString() + '; ') : '');
}
}; };
/** /**