cancel
Showing results for 
Search instead for 
Did you mean: 

Magento2 Varnish issues with customer session and site header

Magento2 Varnish issues with customer session and site header

Hi

Magento version: C.E 2.3.5
Varnish: varnishd (varnish-4.1.1 revision 66bb824)

I am facing a very strange issue. In the admin panel,
Stores -> Configuration -> Advanced -> System -> Cache -> Varnish (recommended)

Now, varnish is enabled on my application.
1. I log into a customer account
2. Access some category pages, homepage, product pages. In my header, I see "Welcome <user>".
3. I logout from the application

4. Now when the system automatically redirects to hompage (after 5 seconds of logout), in the header, I still see the dropdown with options "My acount", "wish list", logout.
5. If I access the already opened pages like, category pages, product pages, the same issue appears. 

Expected result:
In the header, the labels, "Sign In  or Create Account" should appear after logout.

Actual Result:
The system serves the cached version of the page, with a dropdown to logout for an already logged out user.

Did anyone faced any similar issues?

4 REPLIES 4

Re: Magento2 Varnish issues with customer session and site header

Hello @Anujeet 

 

Are you checking with default theme or custom theme?

 

 

if you are using custom theme, then may be not compatible with varnish

 

Check below thing, when you do logout, it should be call one section into network tools. check that section is calling and what is response of that section

 

require('Magento_Customer/js/customer-data').reload('customer');

run above code into network console and check it what happen


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Magento2 Varnish issues with customer session and site header

Hi @Sunil Patel, thank you very much for looking into it.
I am facing the same issue on a default magento setup and my custom theme as well.

Let me tell you the steps I did.
1. I go through some pages, like hompage, category page, product page, again and again, so that I get cached version served.

I see "Sign In" or "Create an account" in the header.

2. I log into the application as a customer "Anujeet", and then I revisit the same pages.
Now I get the following three things in header:
Welcome Anujeet Kaur
Sign In 
Create an account

Its strange, right?

3. Now that I have reproduced the error, I ran the below code in Console:

require('Magento_Customer/js/customer-data').reload('customer');


I see an error in console and also 400 Bad Request in Network console.
The request URL is 
customer/section/load/?sections=c%2Cu%2Cs%2Ct%2Co%2Cm%2Ce%2Cr&_=1593154058135


 And the response is 
{"message":"The &quot;c&quot; section source isn&#039;t supported."}
which is : The "c" section source isn't supported.

The error in console is:
customer-data.js:95 Uncaught Error: [object Object]

which is the below function:

getFromServer: function (sectionNames, forceNewSectionTimestamp) {
var parameters;

sectionNames = sectionConfig.filterClientSideSections(sectionNames);
parameters = _.isArray(sectionNames) ? {
sections: sectionNames.join(',')
} : [];
parameters['force_new_section_timestamp'] = forceNewSectionTimestamp;

return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {
throw new Error(jqXHR);
});
}


Many Thanks!



Re: Magento2 Varnish issues with customer session and site header

Hello @Anujeet 

 

: The "c" section source isn't supported.

 

may  be in some of module you try to create c section but not removed.

 

if still you not find then check into incognito mode 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Magento2 Varnish issues with customer session and site header

Hi @Sunil Patel 
But I checked this on the default magento setup. I have no extra modules installed there?

Thanks