We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Are you logged into the manager in Firefox? That makes no sense. Do you have a session_cookie_domain set?
      • 17499 ☆ A M B ☆
      • 872 Posts
      I’m logged in the backend but with Chrome, not firefox.
      I don’t have session_cookie_domain set (is it a parameter of MODx - if yes, it doesn’t appear in the system settings)
        • 17499 ☆ A M B ☆
        • 872 Posts
        I tried it once again at home this time with the latest release (2.0.6).

        I created a second context called "web2" with the following setting:

        base_url "/"
        http_host "test2"
        site_name "My second context"
        site_start "2"
        site_url "http://test2/"
        


        My virtual host is as follow:

        <VirtualHost *:80>
            ServerAdmin [email protected]
            DocumentRoot "d:/SVN/TEST/"
            ServerName test2
            ErrorLog "logs/test2-error.log"
            CustomLog "logs/test2-access.log" common
        	<Directory "d:/SVN/TEST/">
                Options Indexes FollowSymLinks 
        		AllowOverride all
                Order Deny,Allow
                Deny from all
                Allow from 127.0.0.1
            </Directory>
        </VirtualHost>
        


        To switch context i use this plugin code:

        <?php
        if($modx->context->get('key') != "mgr"){
        	switch($modx->getOption('http_host')){
        		case 'test2:80':
        		case 'test2':
        			$modx->switchContext('web2');
        			break;
        		default:
        			break;
        	}
        }
        


        Permissions for anonymous is set for both context to:
        contextname - Member 9999 - Load Only
        



        I did not load any custom template and use the default basic template with MODx and the resources content (only 2 resources that are site_start foreach context) are just "lorem Ipsum".

        I tried it with FF after a clear cache (with all FF extensions disabled), it show me a 404 error and here is the log:
        127.0.0.1 - - [20/Dec/2010:20:28:14 +0100] "GET / HTTP/1.1" 404 146
        


        Then i did the same with Opera (but i manually cleared the cache each time before reload) it succeed each times:
        127.0.0.1 - - [20/Dec/2010:20:28:30 +0100] "GET / HTTP/1.1" 200 849
        


        Now, with a clean FF profile, it succeed as well:
        127.0.0.1 - - [20/Dec/2010:21:25:28 +0100] "GET / HTTP/1.1" 200 849
        


        So it’s an issue with FF, on 2 different hardware and install.
        Now it would not be such a big issue if there was not any other problem but it gets weirder.

        If i drop a [[Login]] Component in the web context it works, but it doesn’t in the second context. At least not entirely.
        If i enter false credential it shows the correct error message, but i enter the right one, it just reload the page (or go to the specified loginResourceId) but the user is not logged in and after further control hasNoSessionContext... worse, it he stays as an Anonymous user...

        And this problem is for every browser tested.

        I can provide more details if necessary, i really need help on this issue.

        A Drowning Modxer
          • 17499 ☆ A M B ☆
          • 872 Posts
          Back on my last problem.

          It seems that the plugin code cause the Login snippet to fail.
          If i use a switch statement directly in the index.php file (taken from here - That’s also why my first attempt following that example worked correctly) it solved all my issues with both reload in FF and Login in different context than "web".

          Now, i would rather use a plugin instead of hacking the "index.php" file. Any idea what went wrong with this tiny plugin?

          <?php
          if($modx->context->get('key') != "mgr"){
          	switch($modx->getOption('http_host')){
          		case 'test2:80':
          		case 'test2':
          			$modx->switchContext('web2');
          			break;
          		default:
          			break;
          	}
          }
          
            • 22303 MODX Staff
            • 10,725 Posts
            The problem you are facing is that browser session cookies are always domain specific. You cannot login to domain A (as context A) and be logged in on domain B, even if you try to use the Login component to login to context B at the same time as context A, because each domain has a different session cookie.

            You can accomplish something like this on sub-domains by allowing the session cookie to apply to all sub-domains. In order to do that, you will need to create a new system setting called session_cookie_domain with your domain name preceded by a dot, e.g.
            .domain.tld

            This tells PHP to set the session cookie in your browser for any sub-domain of domain.tld. With this you can login to multiple contexts; they just have to be on the same domain.
              • 17499 ☆ A M B ☆
              • 872 Posts
              Thanks for the clarification.

              The onHandleRequest event only allow to switch Context but if we want to initialize a different context than web (but use only one landing page and no subdirectory), we have to directly edit the index.php file.
              This is definitively not a deal breaker but can we hope to have an event to bypass/replace the default initialize if needed before handleRequest ?
                • 22303 MODX Staff
                • 10,725 Posts
                Quote from: lossendae at Dec 20, 2010, 05:44 PM

                Thanks for the clarification.

                The onHandleRequest event only allow to switch Context but if we want to initialize a different context than web (but use only one landing page and no subdirectory), we have to directly edit the index.php file.
                This is definitively not a deal breaker but can we hope to have an event to bypass/replace the default initialize if needed before handleRequest ?
                I use it with separate virtual hosts; the idea was that we would have a gateway template (representing index.php) and that it could be placed in various virtual hosts with the proper context initialization. For your scenario, triggering an event at that point for those who don’t need it, could possibly degrade performance, but it is certainly a good feature request in any case. Perhaps we can come up with a way to template that as well, letting setup construct the switch statement needed for the initialization decision.
                  • 24351
                  • 15 Posts
                  I just want to report, that I am facing the same problems.

                  The caching issue exists. but if I have my gateway in the index.php it works. (local developpment xampp2)
                  The uploaded page works with the OnHandleRequest. No caching problems at all (unix)

                  The Login snippet doesn’t work on my local environment. It loggs in... on successful login, it forwards to the login target page. All fine. But the data doesn’t get persisted in the session.

                  Anyhow the online version with unix works just fine.

                  Unfortunately I sofar can’t report any solution for this problem. But i will post back if I find something.

                  Cheers