mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 05:20:30 +03:00
Set cookies on the client side as secure and safe to set as third party if possible
This commit is contained in:
parent
098abccde7
commit
423ef8d36f
@ -57,11 +57,14 @@ var Mibew = Mibew || {};
|
||||
* omitted a session cookie will be created.
|
||||
*/
|
||||
Mibew.Utils.createCookie = function(name, value, expires) {
|
||||
var domain = /([^\.]+\.[^\.]+)$/.exec(document.location.hostname);
|
||||
document.cookie = "" + name + "=" + value + "; "
|
||||
+ "path=/; "
|
||||
+ (domain ? ("domain=" + domain[1] + "; ") : '')
|
||||
+ (expires ? ('expires=' + expires.toUTCString() + '; ') : '');
|
||||
if (navigator.cookieEnabled) {
|
||||
var domain = /([^\.]+\.[^\.]+)$/.exec(document.location.hostname);
|
||||
document.cookie = "" + name + "=" + value + "; "
|
||||
+ "path=/; "
|
||||
+ (document.location.protocol == 'https:' ? "SameSite=None; secure; " : '')
|
||||
+ (domain ? ("domain=" + domain[1] + "; ") : '')
|
||||
+ (expires ? ('expires=' + expires.toUTCString() + '; ') : '');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user