Post by HAO » Fri Aug 09, 2024 1:39 pm

This is the modification method provided by ADD Creative, The modifications he provided really helped me solve the problem in 3.0.3.8.

But there are two code changes in this method, Even if use the old method to modify it, an error message will appear.

Code: Select all

[08-Aug-2024 17:25:01 UTC] PHP Fatal error:  Uncaught Exception: Error: MySQL server has gone away<br />Error No: 2006<br />REPLACE INTO `oc_session` SET `session_id` = '71af37c98c224a6c6592326a27', `data` = '{\"language\":\"zh-tw\",\"currency\":\"TWD\"}', `expire` = '2024-08-08 22:25:01' in /home/***/public_html/system/library/db/mysqli.php:49
Stack trace:
#0 /home/***/storage/modification/system/library/db.php(55): DB\MySQLi->query('REPLACE INTO `o...')
#1 /home/***/public_html/system/library/session/db.php(28): DB->query('REPLACE INTO `o...')
#2 /home/***/public_html/system/library/session.php(81): Session\DB->write('71af37c98c224a6...', Array)
#3 [internal function]: Session->close()
#4 {main}
  thrown in /home/tylee/public_html/system/library/db/mysqli.php on line 49
How can i solve this problem?

For PHP 7.3, try.

In catalog/controller/startup/session.php change.

Code: Select all

setcookie($this->config->get('session_name'), $this->session->getId(), ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
To.

Code: Select all

setcookie($this->config->get('session_name'), $this->session->getId(), ['expires' => ini_get('session.cookie_lifetime'), 'path' => ini_get('session.cookie_path'), 'domain' => ini_get('session.cookie_domain'), 'samesite' => 'None', 'secure' => true, 'httponly' => true]);
In system/framework.php change.

Code: Select all

setcookie($config->get('session_name'), $session->getId(), ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain'));
To.

Code: Select all

setcookie($config->get('session_name'), $session->getId(), ['expires' => ini_get('session.cookie_lifetime'), 'path' => ini_get('session.cookie_path'), 'domain' => ini_get('session.cookie_domain'), 'samesite' => 'None', 'secure' => true, 'httponly' => true]);
in catalog/controller/startup/startup.php.
Change.

Code: Select all

setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
To.

Code: Select all

setcookie('language', $code, ['expires' => time() + 60 * 60 * 24 * 30, 'path' => '/', 'domain' => $this->request->server['HTTP_HOST'], 'samesite' => 'None', 'secure' => true]);
Change.

Code: Select all

setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
To.

Code: Select all

setcookie('currency', $code, ['expires' => time() + 60 * 60 * 24 * 30, 'path' => '/', 'domain' => $this->request->server['HTTP_HOST'], 'samesite' => 'None', 'secure' => true]);
Old:
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
OpenCart 3.0.4.0
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/');
Old:
setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
OpenCart 3.0.4.0
setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/');
Please help me, Thank you!

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm

Post by paulfeakins » Fri Aug 09, 2024 7:09 pm

HAO wrote:
Fri Aug 09, 2024 1:39 pm

Code: Select all

MySQL server has gone away
This means your web host can't handle the traffic, consider moving to our hosting: https://www.antropy.co.uk/opencart-serv ... t-hosting/

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom
Who is online

Users browsing this forum: No registered users and 20 guests