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

    Having spent the last 3 hours reading everything I can find and exhausted Google, the MODx sites (forum & rtfm) I was wondering if anyone had actually solved the multi-context login conundrum?

    I have several contexts, but lets keep this simple and address (what actually may be the main issue - http/https?).
    The issue is NOT http/https related (hindsight is always 20/20) but naturally this was never the problem, see below...

    The software and versions;


    • MODx Revolution 2.0.8-pl (traditional)
    • login - 1.5.2

    The following are 2 contexts that I would dearly love to get working;

    context 1 : web : http://foo.org
    context 2 : secure : https://secure.foo.org  <- NOTE https, not http
    


    I need to have the Login and subsequent ’member’ only pages/areas running under HTTPS.

    To start with here is what I have achieved;


    • Enabled the contexts with cross linking
    • Established the Register and Login with all support utilities - email activation, forgot password, profile, update profile etc... under Context 2, the https - this is important!
    • Tried using &contexts=`web` in the [[!Login?]] call -> [[!Login? &tplType=`modChunk` &loginTpl=`lgnLoginTpl` &loginResourceId=`122` &contexts=`web`]]
    • Tried (after removing the &contexts) <input type="hidden" name="add_contexts" value="web" />
    • Neither worked. And the [[+modx.user.username]] tag results in either my administration username (if logged in as a manager) or (anonymous) in the ’web’ context

    Solution
    Part 1

    Add &contexts=`foo_context,bar_context,etc` in the [[!Login?]] call e.g;
    [[!Login? &tplType=`modChunk` &loginTpl=`lgnLoginTpl` &loginResourceId=`123` &contexts=`foo,bar,etc`]]
    


    Part 2
    Thanks to OpenGeek for this;

    http://modxcms.com/forums/index.php/topic,57908.msg331246.html#msg331246

    Set a system setting, session_cookie_domain, with a value of:
    .domain.tld


    Clear your cache, and hey-presto, it works.

    Am I onto a losing battle here? Can 2 contexts (or more) be logged into if switching between http & https? Also if I am missing required info, please let me know and I shall endeavour to add it.

    Many regards and any answer at all appreciated,
    A big thank you to the developers and users of MODx, you’re making my life happier.
    Dave
      • 2807
      • 20 Posts
      One caveat to this approach is that any subdomains not included in your ’main’ site as a context will have to be logged into using a different Browser/UA. This is because of the ’wildcard’ cookie.