Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem when I add a product in cart first time #42

Open
thiagorock22 opened this issue Dec 22, 2015 · 5 comments
Open

Problem when I add a product in cart first time #42

thiagorock22 opened this issue Dec 22, 2015 · 5 comments

Comments

@thiagorock22
Copy link

I noticed when I visit my ecommerce first time the cookie key "frontend" is not created, only after visit area that doesn't have a cache. The problem is when I use ajax to add a cart and there is no a cookie key "frontend", the cart remains empty.
How I resolve it?

@phizab
Copy link

phizab commented Dec 30, 2015

We noticed the same problem and solved it by changing the file app/design/frontend/base/default/template/varnishcache/cookie/formkey.phtml in line 33:

From:
if (document.cookie.length && (document.cookie.indexOf('=') == -1)) {

To:
if (document.cookie.indexOf('=') == -1) {

Does anybody know why there is the cookie length check?

@dleone81
Copy link

dleone81 commented Jan 7, 2016

I've tried your fix and works on Magento single store!
I've a multi-store Magento installation and I following your tip and added some additional steps:

  1. I've not hardcoded varnishcache/cookie/formkey.phtml but I've created this into my custom template folders -> app/design/frontend/**default/mycustomtemplate/**template/varnishcache/cookie/formkey.phtml
  2. Added in System > Configuration > General > Web > Cookie Session, foreach domain I've add the specific url as www.mydomain.com and b2b.mydomain.com
  3. Flush Magento cache
  4. Clear all cache
  5. Clear Varnish cache
  6. Restart Varnish (optional but recommended)

Thank you

Magento 1.8.1
Varnish 3.0
NginX + PHP-FPM

@xinhus
Copy link

xinhus commented Feb 24, 2016

I've solved it with the setting "Use SID on Frontend" to "yes"
System > Configuration > General > Web > Session Validation Settings

I don't know if has logic, but worked fine

@Emulator000
Copy link

Same issue here, if I open the site the first time in Incognito mode I can see a different form_key generated and the PAGECACHE_FORMKEY is different also after refreshing the page etc.
Can't add any Product to the cart and the site is unusable.

I'm missing something? How I can make it work correctly every time someone visit the site?

@dleone81
Copy link

dleone81 commented Apr 29, 2016

solved using Lesti-FPC!
Varnish make me crazy ... it was very very fast on loading but so hard to configure no-cache elements as megamenu ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants