M
M
Maxim Uvarov2016-11-22 16:11:19
Laravel
Maxim Uvarov, 2016-11-22 16:11:19

Saving localization on subdomains?

I ran into a problem when implementing localization when working with subdomains. The subdomains themselves have nothing to do with localization (this is not ru.domain.com!) The essence of the problem is as follows - localization works only in the subdomain, in the group of routes of which there is a route with a locale change controller.
Those. if the locale change route is sub1.domain.com/lang/ru, then localization works only in the space sub1.domain.com/...
On the subdomain " sub2.domain.com/... " localization does not work and values ​​from localization files do not pull up. At the same time, App::getLocale() on " sub2.domain.com/... " shows that the locale was successfully changed.
I can't figure out where to dig if App::getLocale() shows ['en'] , and the template outputs the value from the localization file 'ru'.
The general principle of changing the locale is implemented according to the example https://habrahabr.ru/post/264435 , only the logic from the route is removed to the controller.
I tried to create one global group, in the root of which to place the route of the locale change controller and the subdomain group - it did not help.
Help me please...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Uvarov, 2016-11-22
@primevendetta

Found a solution.
Cookies, like the session, must be shared across all subdomains.
Since all cookies in Laravel are protected, you can only share them in plain text like this .
With sessions, everything is simpler - you need to add a dot at the beginning of ".domain.com" to the value of SESSION_DOMAIN in config/session.php
I chose the option with the session. It turned out that you just had to put a dot in the right place :)

A
Alexander Aksentiev, 2016-11-22
@Sanasol

remove in cookies, not in session

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question