Page 1 of 1

OC2.3, main page won't use the cookie currency value

Posted: Thu Sep 03, 2020 11:56 am
by takayuki
Hi,

If I change the cookie currency value from USD to JPY, for example, from an external myOCsite.com/currencyswitch.php page like this:

Code: Select all

$ccode='JPY';
setcookie('currency', $ccode, time() + 60 * 60 * 24 * 30, '/', ".myOCsite.com");
I can verify the currency value is set to JPY in the cookie via the cookie viewer in Chrome.

**BUT**

When I ctrl-r my opencart browser window, USD still loads. And when I check the cookie value in Chrome, it has changed back to USD.

Can anyone shed some light on this? What am I missing? I'm trying to create a separate page on my OC site that loads fast and has a currency switcher, all my code, just accessing the OC db.

thanks,

takayuki

Re: OC2.3, main page won't use the cookie currency value

Posted: Thu Sep 03, 2020 6:12 pm
by ADD Creative
If you look at the code for currency cookie, the session value takes precedence.
https://github.com/opencart/opencart/bl ... #L132-L159

Re: OC2.3, main page won't use the cookie currency value

Posted: Fri Sep 04, 2020 9:17 am
by takayuki
Thanks for the reply. One step closer to a solution. Where are the session values stored for Opencart?

Code: Select all

print_r($_SESSION);
does not return any values.

Thanks,

Takayuki

Re: OC2.3, main page won't use the cookie currency value

Posted: Fri Sep 04, 2020 6:01 pm
by ADD Creative
See.
https://github.com/opencart/opencart/bl ... on.php#L47

Are you looking after the session is started?