Post by Reshovski » Wed Nov 29, 2017 7:00 pm

I do not want to store cookie in the browser for language in opencart 3.x
Previously on Opencart 2.x was made some modification in system/librabry/session.php,
but in Opencart 3.x is different and cannot do it.
My problem comes from that my main page is onepage with only link to several stores in different languages but that main page is set to english and when click on some other store get the language from the default store not the language itself:
mytore.com -> English
gr.mystore.com -> Greek
ro.mystore.com -> Romanian
...
When the clients visit mystore.com they see only the logo of the store and several options for countries that we work and want when client click on the country that want to open that store in the language set in the admin panel, for gr.mystore.com to be Greek.
But when visit at first place mystore.com the browser save cookie with language content EN and then all other sub stores open in that language.
What I'm try till now:
Just modify two files to not store in database any sessions and in the file:
system/library/session/db.php
and
system/library/session/file.php
but still save that cookies.

Maybe will help if make only language cookie to be expire in less then 1 sec or just make to not store that cookie!?

Please if someone can help I'll very happy :)
Last edited by Reshovski on Thu Nov 30, 2017 7:01 pm, edited 1 time in total.

Newbie

Posts

Joined
Tue Feb 28, 2017 5:42 am

Post by straightlight » Wed Nov 29, 2017 9:42 pm

catalog/controller/startup/startup.php file:

Code: Select all

if (!isset($this->session->data['language']) || $this->session->data['language'] != $code) {
			$this->session->data['language'] = $code;
		}
				
		if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) {
			setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
		}
		

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Reshovski » Thu Nov 30, 2017 12:14 am

straightlight wrote:
Wed Nov 29, 2017 9:42 pm
catalog/controller/startup/startup.php file:

Code: Select all

if (!isset($this->session->data['language']) || $this->session->data['language'] != $code) {
			$this->session->data['language'] = $code;
		}
				
		if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) {
			setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
		}
		
Thanks a lot, exactly what I search for.
For more information to other people need that, just comment some rows:

in catalog/controller/startup/startup.php file:
line 97: $this->session->data['language'] = $code;
line 101: setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);

in catalog/controller/common/language.php file:
line 8: $data['code'] = $this->session->data['language'];

Newbie

Posts

Joined
Tue Feb 28, 2017 5:42 am

Post by zbrz » Fri Jul 20, 2018 4:42 am

The solution above doesn't work on 2.3.0.2. Could someone help for the same solution with OC 2.3.x?

Newbie

Posts

Joined
Wed Nov 26, 2014 1:47 pm

Post by masterross » Fri Sep 07, 2018 7:22 pm

Hi Reshovski,

I did comment the code you refer but still the site opens in English!
How to force it to open in default language which is not EN?

Thank you!

Pottery Glaze shop


New member

Posts

Joined
Mon Jan 02, 2017 7:07 pm

Post by straightlight » Fri Sep 07, 2018 7:51 pm

The default language in the OC admin must be switched to your preferred language from your admin - > systems - > localisation - > languages form.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by masterross » Fri Sep 07, 2018 8:27 pm

Dear straightlight,
Of course I did set Default language other than English but site still opens in English on first load.
This is a serious bug and I already one year trying to solve this issue.
Please help!

Pottery Glaze shop


New member

Posts

Joined
Mon Jan 02, 2017 7:07 pm

Post by straightlight » Fri Sep 07, 2018 9:21 pm

If you believe this issue to be a serious bug, try the alpha version (3.1.0.0a from Github) on a separate folder and new database noticing if the issue persists.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by masterross » Sat Sep 08, 2018 3:20 am

After opening a ticket in OC support they provide a solution!
in catalog/controller/startup/startup.php
Find

Code: Select all

 $code = $detect ? $detect : '';
and just comment it!

Also works in OC 2.3

Enjoy!

Pottery Glaze shop


New member

Posts

Joined
Mon Jan 02, 2017 7:07 pm

Post by straightlight » Sat Sep 08, 2018 5:29 am

The reason why this code would be commented out at this point is because the browser code does not correspond with your language pack ...

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: AdsBot [Google], Shiftcom, SohBH and 407 guests