#34901·cypress

cy.request() / cy.visit() keep sending a cleared cookie while following redirects

Author: liiasCreated Sep 23, 2026Updated Sep 23, 2026

Current behavior

When cy.request() or cy.visit() follows a redirect chain, Cypress rebuilds the Cookie header before each redirect from the browser's cookies. But it only replaces the header when the browser has at least one cookie for the redirect URL. If a response in the chain deletes the last cookie (for example, a /logout response that expires the session cookie), the previous request's Cookie header is sent again unchanged.

If the server keeps rejecting that stale cookie and redirecting, the request loops until it hits maxRedirects. It should instead go out without a Cookie header.

Desired behavior

Once the browser has no cookies for the redirect URL, that request should have no Cookie header, or only the one the test set explicitly in headers. Cookies the browser has cleared should not be sent again.

Test code to reproduce

javascript
it('does not send a cookie the redirect response deleted', () => {
  cy.setCookie('session', 'abc', { domain: 'httpbin.org' })

  cy.request('https://httpbin.org/cookies/delete?session')
    .its('body.cookies')
    .should('deep.equal', {}) // fails: { session: 'abc' }
})

Cypress Version

16.1.0

Debug Logs

bash

Other

No response