Modx login and multiple contexts

Dear colleagues,
Our company is developing web sites, based on modx for years.
This is one of the best CMS I ever used
And your community is one of the most valuable sources of information and additions for modx.
My question is related to multilingual modx revolution (2.3) site, based on context switching and Login (Login module).
I was fighting for hours to make the login work for all the frontend contexts.

The multilingual implementation is not with subdomains, but with «folders»
domain.tld/bg/ domain.tld/en/…

Adding &contexts parameter to Login call didn't help

I found some threads in modx forums, which didn't help either.

I managed to make it work, by adding following code to index.php
switch ($_REQUEST['cultureKey']) {
        case 'en':
            $modx->initialize('en');
            break;
        case 'it':
            $modx->initialize('it');
            break;
        default:
            $modx->initialize('web');
            break;
    }
But the login is per context (You have to login to each context separately).
Do you have an idea how can I achieve single login to all frontend contexts.
I would expect such a solution will be useful for other people as well.

Sorry that I'm posting in English, my Russian writing skills are a bit rusty, but you can answer in Russian.

Kind Regards,
Dimitar Dimitrov
Dimitar Dimitrov
03 ноября 2014, 14:59
modx.pro
3 773

Комментарии: 7

Василий Наумкин
03 ноября 2014, 18:06
First of all read this article. There is no need to edit index.php or create folders.

Than you need to specify contexts in Login call:
[[!Login?
	&contexts=`web,en,it`
]]
    Dimitar Dimitrov
    03 ноября 2014, 18:30
    I did it exactly as shown in your article.
    Actually I used the article to create the multilingual switching.
    And the login I called as you suggest.
    But the login didn't work (worked only for web context).
    Then I added
    $modx->initialize('$context');
    before
    $modx->switchContext($context);
    and it didn't work either.

    After I added this to index.php it started to work, but independent per context.
    If you are logged in in web (bulgarian), you are not logged in in en.
    If you login in all context it keeps you logged in
    I think it is somehow related to the user object and probably to the cookie, but for the moment cannot find the reason.
      Василий Наумкин
      03 ноября 2014, 19:14
      Did you try to login from anonymous mode of browser (with no cookies and session)?
        Dimitar Dimitrov
        03 ноября 2014, 19:41
        Yes.
        And from different browser as well.
        The strange thing is that people say it should work.
        Most of the discussions are actually for subdomain based multilingual implementation.
        I have to evaluate the Login code and see how the contexts parameter is working. It looks to me that it authenticates the user for current context only.

        But I can try to sell current behavior to the customer as a feature — separate logins per language :-)
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
7