Page 2 of 2

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Thu Sep 17, 2020 11:28 pm
by letxobnav
oc always loads the default framework.php

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Sep 18, 2020 12:50 am
by LocalExamination
ADD Creative wrote:
Thu Sep 17, 2020 10:08 pm
Have you refreshed your modifications?
Yes of course.

letxobnav wrote:
Thu Sep 17, 2020 11:28 pm
oc always loads the default framework.php
Seems so, it is one file that can't be ocmodified. It applies changes, but never loads the modified version.

The only solution is to hard code it and wait for an official fix.

Thanks anyway.

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Sep 18, 2020 1:31 am
by ADD Creative
LocalExamination wrote:
Fri Sep 18, 2020 12:50 am
ADD Creative wrote:
Thu Sep 17, 2020 10:08 pm
Have you refreshed your modifications?
Yes of course.
Sorry, I misunderstood your post. I thought you had made the changes to the core files. If you didn't want to change the core files you could try to modify the Set-Cookie headers with your web server. A quick web search should give you a few examples.

Re: Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Thu Nov 05, 2020 2:11 am
by stavrosa
Solved, for me too!
ADD Creative wrote:
Sat Aug 22, 2020 9:48 pm
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]);
For the language and currency cookies, they should be the same as in this post.
viewtopic.php?f=190&t=216579&start=20#p796020

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Tue Nov 17, 2020 9:18 am
by webdesires
We have released a plugin that handles all this for you - Secure Cookies & Sessions (with Strict, Lax, None samesite)

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Sun Dec 13, 2020 8:28 am
by wegabt
I am using opencart 3.0.6. The problem still continues. Anyone can solve it?

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Sun Dec 13, 2020 10:51 pm
by ADD Creative
wegabt wrote:
Sun Dec 13, 2020 8:28 am
I am using opencart 3.0.6. The problem still continues. Anyone can solve it?
You will have to give more information. Actual OpenCart version (there isn't a 3.0.6). PHP version. Link to your site. What you have tried so far.

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Sun Dec 13, 2020 11:09 pm
by wegabt
version 3.0.3.6 www.silyver.com

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Sun Dec 13, 2020 11:23 pm
by ADD Creative
wegabt wrote:
Sun Dec 13, 2020 11:09 pm
version 3.0.3.6 www.silyver.com
Your session cookie looks correct.

Code: Select all

set-cookie: OCSESSID=xxx; path=/; secure; HttpOnly; SameSite=None
You will need to describe your issues in more detail.

Re: Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Oct 29, 2021 5:23 pm
by Ctsimpos
ADD Creative wrote:
Sat Aug 22, 2020 9:48 pm
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]);
For the language and currency cookies, they should be the same as in this post.
viewtopic.php?f=190&t=216579&start=20#p796020
This works assuming changes to framework are done on core file.
HOWEVER the link for currency and language only refers to 2.3 OC and it does NOT work on OC 3

does anyone have a solution for language and currency for OC 3 and php 7.3?

many thanks

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Oct 29, 2021 6:30 pm
by ADD Creative
Not that the language and currency cookies should be an issue, but if you did want to change them, 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]);

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Aug 09, 2024 5:13 am
by HAO
ADD Creative wrote:
Fri Oct 29, 2021 6:30 pm
Not that the language and currency cookies should be an issue, but if you did want to change them.
This is the modification method you provided, But it is no longer available in OpenCart 3.0.4.0:

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, '/');
The red code has been removed, So the original code cannot be used again, How can I modify the code to solve this problem?

Can you help me?

Thank you!

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Aug 09, 2024 4:02 pm
by ADD Creative
HAO wrote:
Fri Aug 09, 2024 5:13 am
The red code has been removed, So the original code cannot be used again, How can I modify the code to solve this problem?

Can you help me?

Thank you!
Change.

Code: Select all

setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/');
To.

Code: Select all

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

Code: Select all

setcookie('currency', $code, time() + 60 * 60 * 24 * 30, '/');
To.

Code: Select all

setcookie('currency', $code, ['expires' => time() + 60 * 60 * 24 * 30, 'path' => '/', 'samesite' => 'None', 'secure' => true]);

Re: [SOLVED] Help: How to put the attribute SameSite "none" in cookies. ? OP 3.0.3

Posted: Fri Aug 09, 2024 5:11 pm
by HAO
Thank you for your help! ;D