Skip to content

Commit

Permalink
#5011 Fix to set Secure attribute on cookie when SameSite=none (#5064)
Browse files Browse the repository at this point in the history
* #5011 Fix to set Secure attribute on cookie when SameSite=none

* Minor change to use const instead of var per review request.
  • Loading branch information
goosemanjack authored Apr 7, 2020
1 parent 036d71d commit 8275fc1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/storageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export function newStorageManager({gvlid, moduleName, moduleType} = {}) {
if (result && result.valid) {
const domainPortion = (domain && domain !== '') ? ` ;domain=${encodeURIComponent(domain)}` : '';
const expiresPortion = (expires && expires !== '') ? ` ;expires=${expires}` : '';
document.cookie = `${key}=${encodeURIComponent(value)}${expiresPortion}; path=/${domainPortion}${sameSite ? `; SameSite=${sameSite}` : ''}`;
const isNone = (sameSite != null && sameSite.toLowerCase() == 'none')
const secure = (isNone) ? '; Secure' : '';
document.cookie = `${key}=${encodeURIComponent(value)}${expiresPortion}; path=/${domainPortion}${sameSite ? `; SameSite=${sameSite}` : ''}${secure}`;
}
}
if (done && typeof done === 'function') {
Expand Down

0 comments on commit 8275fc1

Please sign in to comment.