0
Welcome Guest! Login
0 items Join Now

carry a logged in users details to a non joomla subdomain

  • carry a logged in users details to a non joomla subdomain

    Posted 15 years 8 months ago
    • I posted this on Joomla's site but got no response. Hopefully you guys can help since you're pro at this stuff...

      I have joomla installed in my main root directory. I have a subdomain that I want to carry a users login details to.

      main joomla site : mysite.com [/home/mysite/public_html]
      subdomain not using joomla :sub.mysite.com [home/mysite/public_html/sub]

      the code I have at the top of the sub domain file is this.
      <?php
       
      define( '_JEXEC', 1 );
       
      define( '_VALID_MOS', 1 );
      // JPATH_BASE should point to Joomla root directory
      // if you app is placed into a subfolder in Joomla root, the path will look like dirname(__FILE__) . '/..'
      define( 'JPATH_BASE', realpath(dirname(__FILE__) .'/..' ) );
       
      define( 'DS', DIRECTORY_SEPARATOR );
       
      require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
       
      require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
       
      $mainframe =& JFactory::getApplication('site');
       
      $mainframe->initialise();
       
      $user =& JFactory::getUser();
       
      $session =& JFactory::getSession();
       
      echo $user->username;
       
      ?>

      After i login to joomla at "mysite.com" I navigate to "sub.mysite.com" where the above code is located but no user details are carried.

      Can someone help me with what I need to do?
  • Re: carry a logged in users details to a non joomla subdomain

    Posted 15 years 8 months ago
    • ok the problem was with joomla setting sessions for subdomains

      this is how i fixed i. Hope it helps anyone else that needs it.


      Step 1 :
      Open File : [ libraries/joomla/session/session.php ]

      Step 2 :

      find lines 422-423
      session_cache_limiter('none');
      session_start();
      replace with
      ini_set('session.cookie_domain', '.yoururl.com');
      session_cache_limiter('none');
      session_start();
      Replace ".yoururl.com" with your domain name.
      Note : BE SURE YOU LEAVE THE PERIOD BEFORE YOUR DOMAIN NAME

      Step 3 :
      Open File [ libraries/phpxmlrpc/xmlrpc.php ]

      find line 1082
      $this->cookies[$name]['domain'] = $domain;
      replace with
      $this->cookies[$name]['domain'] = '.yoururl.com';

      Make sure you clear all your browser sessions and cookies. Then try logging in and going to one of your subdomains.

Time to create page: 0.061 seconds