Fix issue with the timing of setting cookies in the browser
See original GitHub issueCurrently, if a cross-origin request sets a cookie and the app attempts to read the cookie via document.cookie
synchronously on page load, the document.cookie
value will not be correct / up-to-date.
Spec:
it('document.cookie includes cookie set by http request', () => {
cy.get('[data-cy="cookie-login-land-on-document-cookie"]').click()
cy.origin('http://foobar.com:3500', { args: { username } }, ({ username }) => {
cy.get('[data-cy="username"]').type(username)
cy.get('[data-cy="login"]').click()
})
cy.origin('http://idp.com:3500', { args: { username } }, ({ username }) => {
cy.get('[data-cy="document-cookie"]').invoke('text')
.should('include', `user=${username}`)
})
})
App:
<p>
<strong>document.cookie:</strong>
<span data-cy="document-cookie"></span>
</p>
<script>
document.querySelector('[data-cy="document-cookie"]').textContent = document.cookie;
</script>
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:5
Top Results From Across the Web
Clear, enable, and manage cookies in Chrome - Google Support
On your computer, open Chrome Chrome . · At the top right, click More More and then Settings Settings . · Under "Privacy...
Read more >How to Fix Login Issues with Browser Cookies - MyDomain
How to Fix Login Issues with Browser Cookies · Open Chrome. · Click Safari in the menu bar and select Preferences. · Open...
Read more >php - Why are my cookies not setting? - Stack Overflow
It might be a cache problem. Try closing the browser and opening a new one with the localhost file path.
Read more >7 Keys to the Mystery of a Missing Cookie - Medium
Troubleshooting tip: In Chrome type in the URL chrome://flags and disable these two flags: SameSite by default cookies and Cookies without ...
Read more >Login issues related to browser cookies | Atlassian Support
How to allow cookies · Go to Control Panel > Internet Options. · Select the Privacy tab. · Under Settings, select Advanced. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not sure how helpful this is, but my particular test is good to go up to 10.3.
When run from 10.3.1 my test fails in a unique way unlike 10.4+ When run from 10.4+ my test fails as described in #23565
Let me know if any more detail would be helpful, I’ll do the best I can.
Released in
10.11.0
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v10.11.0, please open a new issue.