We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45533
    • 23 Posts
    One more Update. The session_cookie_domain was in my case a bad idea - cause the session cookie was always overwritten. so i removed it. i have now the situation that i can login directly from from the corresponding context but not from outside (so a login from the web context for the others - just still wont work).

    i tried this:

    
    $primeResponse = $this->modx->runProcessor('security/login',$procConfig);
            
            if(!empty($procConfig['add_contexts'])){
                foreach(explode(',', $procConfig['add_contexts']) as $ac){
                    if(!empty($ac)){
                        
                        $secConfig = array(
                            'login_context' => $ac,
                            'add_contexts' => 'web',
                            'username' => $fields['username'],
                            'password' => $fields['password'],
                            'returnUrl' => $fields['returnUrl'],
                            'rememberme' => !empty($fields[$this->getProperty('rememberMeKey','rememberme')]) ? true : false,
                        );
                        
                        $this->modx->runProcessor('security/login', $secConfig);
                        $this->modx->log(modX::LOG_LEVEL_ERROR, 'Executed extra Login for '.$ac);
                        
                    }
                }
            }
    
    return $primeResponse;
    


    in my LoginController now - it gets executed but i still dont have a user in those other Contexts...
      • 3749
      • 24,544 Posts
      I'm not sure I understand the problem, but possibly this would help:

      $modx->switchContext('contextName');


      BTW, what you're experiencing is why I never use multiple contexts if there's any way to avoid it. wink
        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
        • 45533
        • 23 Posts
        Yeah i'm already about to drop that idea - just because modx can't do it for some reason sad

        The Context get's already switched in a Plugin which is listening on OnHandleWebRequest - i also can see the resources under the other Contexts the Problem is - i need to login again there (anonymous) - there is no way to login to the other Contexts (i would'nt care to have a different session...) i was basically just looking for a single login to all contexts now.

          • 3749
          • 24,544 Posts
          Can't you use the Login snippet and set its &contexts property?
            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
            • 45533
            • 23 Posts
            Oh i'd tried Login already a few ago. Basically my Login Solution is using the same core processor and - well - its kinda the same at all - the only difference is - i need some more logic and custom events after the basic authentication, the hook mechanic was just not enough for that.

            Just to be sure i just tried it once more with the newest version of login - its the same behavior. I can login on the current context - but i can't spread the login session to other contexts.

            For the current project purposes i will stick with multi contexts, cause just Staff Member will need to login twice per session i guess... maybe i'm able to find a fix one day (i still dont wanna accept - that it does'nt work).

            The funny thing is - over my Research i figured - that's an issue which is arround since a few years - and there was already a few fixes - which worked temporaly - but they stopped working on later Releases.

            Anyway - i learned again a lot about the modx core through this smiley - thanks for your input and patience smiley

            • discuss.answer
              • 45533
              • 23 Posts
              Sometimes it's good to not accept - something is not working smiley

              I was looking through the Classes again and wrote here and there Variables into the Console to figure that i have just a different Session ID on the other Context.

              So i set the session_cookie_domain again - and now i got exactly the behavior i was looking for

              Thanks for your Answers. smiley I'm in love with modx again
                • 3749
                • 24,544 Posts
                I'm glad you got it sorted. 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