We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40385
    • 75 Posts
    Hello,

    I'm basically having a similar issue described in this (http://forums.modx.com/thread/?thread=57908&i=1&page=2) and some other threads.

    However the solutions provided are not working for me.

    I'm having two contexts:

    1. web (default) => example.com/de
    2. English => example.com/en

    I'm using Babel in combination with this gateway plugin to switch the contexts:

    if($modx->context->get('key') != "mgr"){
                    /* grab the current langauge from the cultureKey request var */
                    switch ($_REQUEST['cultureKey']){
                      case 'en':
                            /* switch the context */
                            $modx->switchContext('English');
                            break;
                        default:
                            /* Set the default context here */
                            $modx->switchContext('web');
                            break;
                    }
                    /* unset GET var to avoid
                     * appending cultureKey=xy to URLs by other components */
                    unset($_GET['cultureKey']);
                }


    My login snippet call is the following:

    [[!Login? &contexts=`web,English`]]


    Expected behavior: I can login from both resources that contain the login snippet and I will be logged in into all contexts mentioned in the snippet call.

    What do I see instead: I can only login from the web context resource. When I switch to the English context the snippet is indicating that I'm not logged in into the English context. When I enter my credentials the page reloads and I'm prompted with the form again... sad

    Any ideas? I'm running MODx Revo 2.2.8-pl on PHP 5.3.25.

    PS: When switching to directory based context switching (via index.php, htaccess and config.core.php it is working)

    Thanks in advance

    SOLUTION:

    VERY IMPORTANT: When you are using the Login snippet with the setup above the login will only work with the default web context. All Login calls from other contexts will fail. To bypass this issue the default web context must use "/" as base_url and "http://example.com/" as site_url:

    web context: base_url "/de/" and site_url "http://example.com/de/" -> won't work
    web context: base_url "/" and site_url "http://example.com/" -> will work

    Thanks [ed. note: paul_kemp last edited this post 10 years, 11 months ago.]