Post by Zath » Fri Jan 13, 2023 8:40 pm

3.0.3.7 Logout on new cart item refresh.

Hello.
If I log on and add an item to a new cart, view the cart, change the quantity (or not), use the refresh button, it logs me out immediately.
Log back in, do the same and it takes the change and keeps me in.
Further to that, if I use the browser back option to where I was logged in, it allows me to see items and prices then, when reviewing the items, it says I cant see items unless I'm logged in.

Any ideas please ?

Opencart 3.0.3.7.


User avatar
New member

Posts

Joined
Fri Dec 08, 2017 10:07 am
Location - West Sussex, England

Post by Zath » Wed Jan 18, 2023 7:41 am

Can a mod move this to general support please ?

Opencart 3.0.3.7.


User avatar
New member

Posts

Joined
Fri Dec 08, 2017 10:07 am
Location - West Sussex, England

Post by ADD Creative » Wed Jan 18, 2023 7:46 pm

Could be this issue. https://github.com/opencart/opencart/issues/7008

You may be able to test by using your web browser's developer tool to disable the cache.

The easiest way to fix the lack of cache control headers issue is by making the following change to the framework.

In system/framework.php find the following line at around line 74.

Code: Select all

$response->addHeader('Content-Type: text/html; charset=utf-8');
After that line add the following.

Code: Select all

header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);
Note, using header() rather than $response->addHeader() as the later doesn't apply to redirects. I've noticed recently that Firefox aggressively caches redirects, which can lead to some strange issues.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Zath » Sat Jan 21, 2023 12:18 am

I edited it as suggested and it seemed to work, but after a few goes, it still does it.
Any suggestions ?

Code: Select all

// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');

// Added 20-01-23

header('Expires: Thu, 19 Nov 1981 08:52:00 GMT', true);
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true);
header('Pragma: no-cache', true);

// End Added

$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);

Opencart 3.0.3.7.


User avatar
New member

Posts

Joined
Fri Dec 08, 2017 10:07 am
Location - West Sussex, England

Post by ADD Creative » Sat Jan 21, 2023 1:19 am

Try clearing your browser cache after that change, as it still may be caching.

It it still doing it. Check both your OpenCart and PHP error log and also your web browser's developer console.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom
Who is online

Users browsing this forum: No registered users and 4 guests