question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix issue with the timing of setting cookies in the browser

See original GitHub issue

Currently, 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:closed
  • Created a year ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
boyleccommented, Aug 27, 2022

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.

0reactions
cypress-bot[bot]commented, Oct 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found