Happens when I go to any product page in the back office.

I can access the default store view. I can access the first store view.

But I can't access the second store view without triggering that error :

The error: Invalid security or form key Please refresh the page

Already tried to upgrade max_input_vars from 1000 to 5000 in php.ini

Any idea?

EDIT : So in fact after further investigation, this is the real reason behind all that so the provided answers is different from the linked one.

Here is what happened :

I had an observer on layout load before running.

<event name="layout_load_before">
    <observer name="redirectcustomer_success" instance="Cpy\CheckUrl\Observer\RedirectCustomer" />

That observer was meant to redirect users trying to access my 'pro' store...and it worked properly in frontside.

Sadly I didn't planed that...changing the store view in back office would also trigger the condition of that observer. Looks like for magento; even being on BO; the store is considered as the pro store.

Which mean my current error comes from the fact I'm trying to redirect to the front side from the back office cause I'm entering this condition in my observer

public function execute(Observer $observer){
    $loginRedirectUrl = $this->getCustomerLoginUrl();
    $currentUrl = $this->_urlInterface->getCurrentUrl();
    $fullActionName = $this->request->getFullActionName();
    $currentStoreCode = $this->storeManager->getStore()->getCode();
    $isStorePro = $currentStoreCode == 'pro';

            && $currentUrl != $loginRedirectUrl
            &&  $fullActionName != 'customer_account_forgotpassword'
            && $fullActionName != 'customer_account_createpassword'
            && $fullActionName != 'customer_account_create'
            && $fullActionName != 'customer_section_load') {
            $resultRedirect = $this->responseFactory->create();

Not sure yet of what is the best way to handle things but still this is the real reason behind this issue.

  • I haven't tried with max_session_size_admin I will try that one; thought max input vars didn't work.
    – Claims
    Oct 28, 2021 at 8:23
  • Oh I actually missread that, I though it was just about login but seems more general; I will try to apply thhat patch and see how it goes. Thanks
    – Claims
    Oct 28, 2021 at 8:39
  • Check cookie domain for that website->store in admin configuration Oct 29, 2021 at 9:43
  • @MurtuzaZabuawala The answer is in the edit part of the question. The linked answered the issue
    – Claims
    Oct 29, 2021 at 12:17