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

Setting a cookie for a different domain does not work #5841

Open
Gallaecio opened this issue Mar 2, 2023 · 1 comment · May be fixed by #5946
Open

Setting a cookie for a different domain does not work #5841

Gallaecio opened this issue Mar 2, 2023 · 1 comment · May be fixed by #5946
Assignees
Labels

Comments

@Gallaecio
Copy link
Member

Given a request like:

Request(
    url="https://a.example",
    cookies=[
        {
            'name': 'foo',
            'value': 'bar',
            'domain': 'b.example',
        },
    ]
)

The cookie download middleware will discard the cookie because b.example does not match¹ a.example. The cookie will not only be ignored for the purpose of sending this specific request, which is OK, but it will not be added to the cookie jar either, meaning that if a.example redirects to b.example, the follow-up request to b.example is not going to include this cookie either.

I think we need to make it so that domain-based filtering does not keep a cookie out of the cookie jar, so that we can set a cookie for a different domain on a request with the goal of having that cookie reach the right domain in a redirect scenario.

But we need to make sure that we keep applying the domain filtering to cookies that come in the Set-Cookie header in a response, as doing otherwise would be a security issue.


¹ Understanding by “match” what the cookie specification understands when it defines how user agents must handle Set-Cookie headers.

@emarondan
Copy link
Contributor

@Gallaecio Is it ok if I work on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants