Updated cookie to ensure SameSite is set as Strict #627 (#635)

Fixes #627 .
This commit is contained in:
Abhirup Pal 2020-07-11 14:57:12 +05:30 committed by GitHub
parent bc82070102
commit 638728a58e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,10 +62,10 @@ define([], function () {
localStorageTest = false;
}
// Now test for document.cookie API support
document.cookie = 'tempKiwixCookieTest=working;expires=Fri, 31 Dec 9999 23:59:59 GMT';
document.cookie = 'tempKiwixCookieTest=working; expires=Fri, 31 Dec 9999 23:59:59 GMT; SameSite=Strict';
var kiwixCookieTest = /tempKiwixCookieTest=working/.test(document.cookie);
// Remove test value by expiring the key
document.cookie = 'tempKiwixCookieTest=;expires=Thu, 01 Jan 1970 00:00:00 GMT';
document.cookie = 'tempKiwixCookieTest=; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Strict';
if (kiwixCookieTest) type = 'cookie';
// Prefer localStorage if supported due to some platforms removing cookies once the session ends in some contexts
if (localStorageTest) type = 'local_storage';
@ -167,4 +167,4 @@ define([], function () {
hasItem: settingsStore.hasItem,
getBestAvailableStorageAPI: getBestAvailableStorageAPI
};
});
});