Skip to content

Session cookie is lost after redirecting #25495

@jonasraoni

Description

@jonasraoni

Current behavior

Considering a simple:

cy.visit('/');

And the HTTP response below:

HTTP/1.1 302 Found
Host: 127.0.0.1:8080
Date: Sun, 08 Jan 2023 16:07:27 GMT
Connection: close
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: SESSION_ID=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0
Set-Cookie: SESSION_ID=new_cookie_value
Location: next-url
Content-type: text/html; charset=UTF-8

Notice the Set-Cookie, first removing a cookie, then recreating it, and the presence of the Location header

When Cypress goes to the redirected URL, the cookie is lost.

If I remove the Location header from the response and redirect manually with another cy.visit('/next-url'); OR if I drop the first Set-Cookie header (the one which deletes the cookie), then everything works fine.

Desired behavior

I expect Cypress to behave like the browser, which understands the last Set-Cookie should keep/recreate the cookie.

Test code to reproduce

Small sample available above, I might fork the https://github.com/cypress-io/cypress-test-tiny later, but definitely not at this moment.

Cypress Version

12.2.0

Node version

18.11.0

Operating System

Windows 10

Debug Logs

No response

Other

Original report is here: #19800 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions