Skip to content

Allow "sameSite" cookie property to have value "default".#942

Merged
lutien merged 8 commits intow3c:mainfrom
lutien:allow-samesite-being-optional
Jun 30, 2025
Merged

Allow "sameSite" cookie property to have value "default".#942
lutien merged 8 commits intow3c:mainfrom
lutien:allow-samesite-being-optional

Conversation

@lutien
Copy link
Copy Markdown
Member

@lutien lutien commented Jun 25, 2025

In case, setting the cookie with document.cookie Firefox doesn't set sameSite property. At the moment for BiDi storage.getCookies API we fall back to sameSite property to None but we would like to have a separate value "default" in this case to better reflect the actual browser behavior.
This PR allows sameSite property to have the value default in this case.


Preview | Diff

@lutien lutien requested a review from whimboo June 25, 2025 14:01
Copy link
Copy Markdown
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit. Otherwise it looks fine. Thanks!

index.bs Outdated
otherwise.

1. Let |same site| be "<code>none</code>" if |stored cookie|'s samesite-flag is
1. Let |same site| be null if not set, otherwise "<code>none</code>" if |stored cookie|'s samesite-flag is
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the if not set? Does it mean if |stored cookie|'s samesite-flag is not set?

As I mentioned on bugzilla, at the moment I feel like the samesite cookie spec does not really allow the samesite flag to not be set (https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-same-site#section-4.2) ? But maybe I'm not reading this correctly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the if not set? Does it mean if |stored cookie|'s samesite-flag is not set?

I've updated the sentence, does it sound better now?

As I mentioned on bugzilla, at the moment I feel like the samesite cookie spec does not really allow the samesite flag to not be set (https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-same-site#section-4.2) ? But maybe I'm not reading this correctly.

I think it's probably right that computed value of SameSite should be equal to none/lax/strict. And that we expose now an internal value (similar to web-extensions where it's called unspecified). I'm not sure how critical it's, if we maybe should add something to make it clear that we use a different kind of SameSite (and if it's ok in general). So summoning @jgraham to take a look as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, so it looks like that draft has now been folded into https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-20.html so we should update the reference. That seems to store the values None/Lax/Strict/Default (see step 17 in https://www.ietf.org/archive/id/draft-ietf-httpbis-rfc6265bis-20.html#name-storage-model), so I think Default corresponds to Gecko's "Unset" state, and is probably what we want here.

@lutien lutien requested a review from jgraham June 25, 2025 15:59
Copy link
Copy Markdown
Member

@jgraham jgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting "Request changes" for updating to the new Cookie spec and using that; I know that ends up as potential scope creep for this PR, but I don't think we can do it correctly with the old draft.

@lutien lutien force-pushed the allow-samesite-being-optional branch from d1e4289 to f0e54f2 Compare June 30, 2025 10:14
@lutien lutien changed the title Allow sameSite cookie property to be optional. Allow "sameSite" cookie property to have value "default". Jun 30, 2025
@lutien lutien requested a review from jgraham June 30, 2025 10:16
index.bs Outdated
Comment on lines +6874 to +6875
Note: The definitions of |stored cookie|'s fields are from [[COOKIES]], except
samesite-flag, which is from [[SAME-SITE-COOKIES]].
same-site-flag, which is from [[SAME-SITE-COOKIES]].
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong now, I think; we're just following RFC6265bis everywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, alright, I removed it now. I was just not sure how all these overrides work

@lutien
Copy link
Copy Markdown
Member Author

lutien commented Jun 30, 2025

@sadym-chromium, do you want to take another look? We changed the approach, so would like to confirm that you're still fine with these changes

@lutien lutien requested a review from sadym-chromium June 30, 2025 10:48
@lutien lutien merged commit 8bc9c3c into w3c:main Jun 30, 2025
5 checks passed
@lutien lutien deleted the allow-samesite-being-optional branch June 30, 2025 12:15
github-actions bot added a commit that referenced this pull request Jun 30, 2025
SHA: 8bc9c3c
Reason: push, by lutien

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants