We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36467
    • 73 Posts
    From last few days i am facing strange issue, i cant login to frontend ONLY, using login snippet in IE10 and safari, Its working fine in FF and Chrome. It keeps redirecting to "returnUrl" field set in login chunk which is actually same page you know. Below is the simple snippet call i am using
    [[!Login? &loginTpl=`multiloginT` &logoutTpl=`redirectendT` &rememberMeKey=`rememberme`]]


    After googling for some time, i found something similar to my problem but that didnt worked for me, I am posting it here just in case it helps someone. https://forums.modx.com/thread/76169/intermittent-ie-login-problem

    Whats is strange ?
    Instead of relying only on login snippet, i tried to login using runProcessor, and thats where i get stunned.

    if($_POST){
    	$response = $modx->runProcessor('security/login', array(
    	  'username' => $_POST['username'], 
    	  'password' => $_POST['password'], 
    	));
    
        print_r($response->response)."<br>";
        echo "Logged User Id:".$modx->getLoginUserId();
    }
    

    Above code returns strange output as below
    Array (
     [success] => 1
     [message] => 
     [total] => 0 
     [errors] => Array ( )
     [object] => Array ( 
        [url] => 
        [token] => modx51c448f4ca15f3.04843443_1052931305c07533.32607283 
     )
    ) 
    Logged User Id:0
    

    Print_r line says that i am successfully logged in ([success] => 1) and on the next line it says i am not logged in (0).

    This question has been answered by dinocorn. See the first response.

      • 4943
      • 4 Posts
      a wild guess, are you using multiple contexts? if so did you set the contexts to be logged in to in the login call?

      &contexts=`web,othercontext,someothercontext`

      greets,
      Chaot_s
        • 36467
        • 73 Posts
        Yes i tried that too, it didnt worked. We have another contexts (subdomains), everywhere else its working fine, same code (but diff resource) its logging in . its not working only for the base domain.

        Ex : Its not working for the

        abc.com

        and working fine for

        a.abc.com
        b.abc.com
        c.abc.com

        Note : Looking at the script behavior i think its something related to cookies, When i enter wrong username and password it gives me proper error message, it only fails when i enter correct login details, that means it fails to initialize session.
          • 38290
          • 712 Posts
          May need to change a system setting related to cookies. Half asleep and on mobile atm but will try and get more info
            jpdevries
            • 36467
            • 73 Posts
            No problem, have sound sleep, and thanks for looking into the issue

            Below are my cookie related settings
            1)session_cookie_domain => BLANK
            2)cookiefile => /var/www/vhosts/projectb/......
            3)session_cookie_httponly => YES (I tried switching it to NO, didnt work)
            4)session_cookie_path => BLANK
            5)session_cookie_secure => NO

            Is there anything that needs to check ?
            • discuss.answer
              • 38290
              • 712 Posts
              Try setting session_cookie_path to /
                jpdevries
                • 36467
                • 73 Posts
                Excellent, Your solution worked perfectly. I dont know why my system was working fine before this change, and it stopped working now only.

                Anyways, It's working fine now, many thanks to you.

                Cheers !!
                  • 38290
                  • 712 Posts
                  Cool. Maybe this is something that should be noted in the documentation.
                    jpdevries