Magento Onepagechekout login issue when using Varn

2019-08-08 01:22发布

问题:

I'm using:

  • Magento v1.7.0.2,
  • Varnish cache v3.0.3 and
  • One Page Checkout (OPC) module from IWD (v2.0.9)

I've added routes "onepagecheckout" and "onestepcheckout" to routes which should be excluded from the cache in Varnish.

I can see that OPC page is not loaded from Varnish and works as it should, however, when the quick login form is used on OPC page, it doesn't work properly together with Varnish. Even when all cache items (including Varnish full page cache) have been disabled in Magento Cache Management.

What I get is the following response from /onepagecheckout/index/login/ script:

{"success":true,"redirect":"http:\/\/myhost.com\/onepagecheckout\/index\/index\/"}

the page get's redirected to the shopping cart but I'm still not logged in.

When switching Varnish off, it works just fine.

Does anybody has some experience with this?

Many thanks in advance!

回答1:

Finally solved the issue by adding the following lines to Varnish's VCL file:

if (req.url ~ "^/(index.php/)?(checkout|onepagecheckout)")
{
     return(pipe);
}

although, these two routes were already added to "Routes to exclude from cache" in MADE configuration (seems that having them in the exception list) leads to simple return(pass) in the background.

It is important to use return(pipe); instead of return(pass); to pass all the cookies to client.