PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] How to remember session when redirection occurs?

 August 22, 2022     cypress, e2e-testing, javascript, magento2     No comments   

Issue

I am using Cypress to test Mageto2.

Problem: Whenever I navigate to different parts of the back end I am requested to log in (And Magento redirects to a certain set page after login instead of the requested page)

Question: Is there a way to remember my session when testing with Cypress so I don't have to log in for any redirection to a part of the backed?


Solution

Cypress clears all cookies before each test

Cypress.Cookies.defaults({
  preserve: "adminhtml"
})

see: https://docs.cypress.io/faq/questions/using-cypress-faq.html#How-do-I-preserve-cookies-localStorage-in-between-my-tests

fyi: adminhtml cookie stores admin's session id

EDIT

It appears that in magento 2 admin session id is stored in a cookie named "admin"

Cypress.Cookies.defaults({
  preserve: "admin"
})


Answered By - Vladimir Samsonov
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing