Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨[RUMF-594] specify same site attribute on cookies #431

Merged
merged 1 commit into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function setCookie(name: string, value: string, expireDelay: number) {
const date = new Date()
date.setTime(date.getTime() + expireDelay)
const expires = `expires=${date.toUTCString()}`
document.cookie = `${name}=${value};${expires};path=/`
document.cookie = `${name}=${value};${expires};path=/;samesite=strict`
}

export function getCookie(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/specHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function isIE() {

export function clearAllCookies() {
document.cookie.split(';').forEach((c) => {
document.cookie = c.replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`)
document.cookie = c.replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/;samesite=strict`)
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/scenario/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async function deleteAllCookies() {
for (const cookie of cookies) {
const eqPos = cookie.indexOf('=')
const name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;samesite=strict`
}
})
}
Expand Down