On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Any help in this area would be so much appreciated.
    I have a very similar situation.
    Login works properly from main domain(site.com) and a [[checksession? &context=`web]] and [[checksession? &context=`other`]] both result in true as well as access to the user object [[+modx.user.username]]

    But when same login snippet is added to other subdomain (sub.site.com) the login snippet (although it does redirect to &loginResponse=`1`) results in a false checksession and no user object returned.

    I have tried adding the .site.com to system setting session_cookie_domain but I don’t see any real change.

    • The user has to be logged into each context explicitly. The Login snippet has options for this.
      • i have similar problem, so i’ll ask here ...

        -i have 4 contexts: web,english,slovenian and italian
        -i created 3 user groups users_en, users_si, users_it
        -i have three domains, each domain for each context (without web context)

        i use login addon to register new user in specific user group .. but i have problems with login

        i registered a user on italian domain, so it went to "users_it" group. On "users_it" group i set the context access as "Load Only" with minimun role "Member - 9999" for context "italian"

        with my user i can login on web context .. but i can’t login on italian domain useing italian context .. i can login only on web ... i missed something ?? what i have to do so the users from users_it will be abble to login only on italian domain using italian context ?? .. and EN users for english domain and SI users for slovenian domain?

        Quote from: OpenGeek at Mar 04, 2011, 12:07 AM

        ...The Login snippet has options for this.
        Wheer is this option, how i can use it ?? .. i didn’t see it in docs ? can this cause my problem ?

        thanx
        • Are they different domains? If so, you cannot share the sessions across different domains. If they are subdomains, you can add the session_cookie_domain value as explained earlier in this thread, but you still have to log users into each Context somehow. If sharing the session (across subdomains) the Login extra has a property called &contexts that takes a comma-delimited list of contexts to log a user into.
          • Wheer is this option, how i can use it ?? .. i didn’t see it in docs ? can this cause my problem ?

            It’s just called "contexts" and it’s used like so:

            [[!Login? ... &contexts=`web,italian`]]
              www.darkstardesign.com

              Are you in the Nashville area? Join us for our next MODX meetup!
            • yes i have different domains for each context ... now i tryed to add &contexts=`web,italian,slovenian,english` to login snippet.. and now it works .. thanx to everyone ..

              &context option should be added to rtfm .. and also system setting session_cookie_domain could be in settings with some null value .. in that way i could see it smiley
              • Solution for your Problem?

                Had the same Problem (but one domain instead of different Domains). Login for default context works fine. The second not:

                • Nothing happened after Login
                • Backend says user is logged in
                • for example [[+modx.user.id]] stays empty

                Setup

                • 2 Contexts with Babel
                • gateway to switch contexts
                • Login extra

                Solution which works fine (but only after i made all the 3 changes and cleared the cache via ftp)

                • Add 2 lines of code at the gateway to initialize BOTH contexts (see code at the bottom)
                • Change System Setting: session_cookie_domain: myDomain.de || session_cookie_path: /
                • Add Parameter &contexts=`web-ja,web` to [[!Login]] call

                gateway
                <?php
                // 2 lines of code to initialize the contexts
                $modx->initialize('web');
                $modx->initialize('web-ja');
                
                if($modx->context->get('key') != "mgr"){
                    /* grab the current langauge from the cultureKey request var */
                    switch ($_REQUEST['cultureKey']) {
                        case 'de':
                            /* switch the context */
                            $modx->switchContext('web');
                            break;
                        case 'ja':
                            /* switch the context */
                            $modx->switchContext('web-ja');
                            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']);
                }
                


                login call
                
                [[!Login?
                  &loginTpl=`lgnLoginTpl`
                  &logoutTpl=`lgnLogoutTpl`
                  &errTpl=`lgnErrTpl`
                  &loginResourceId=`[[++login_memberPage]]`
                  &logoutResourceId=`[[*id]]`
                  &contexts=`web-ja,web`
                ]]
                
                • I wonder if this would work as well rather than initializing all contexts:


                  $modx->switchContext('web-ja', true);


                  The second argument tells MODX to reload the context.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                  • YES! Works too. Changed it. Thanks - AGAIN wink
                    • Glad I could help. Thanks for testing that for us and reporting back. smiley
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting