I am trying to achieve single sign on behaviors between PHP/PERL applications and Joomla. The main entry point would be Joomla, which would set up the sessions and other cookie variables that would be used by the external Perl and PHP applications. For PHP Applications, I have used the below code after reading and researching, to check whether the Joomla session is Active.

 $rootFolder = explode(DS,dirname(__FILE__));
  $currentfolderlevel = 1;
  $base_folder = implode(DS,$rootFolder);
  $base_folder= $base_folder.'/'.'xxx';
  array_push($rootFolder, "/xxx");
 if(is_dir($base_folder .DS.'libraries'.DS.'joomla'))   
   define( '_JEXEC', 1 );
   require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
   require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

jimport( 'joomla.user.user');
jimport( 'joomla.session.session');
jimport( 'joomla.user.authentication');
        $mainframe = JFactory::getApplication('site');
        $user =JFactory::getUser();
        $session = JFactory::getSession();
        //$groups  = $options['user']->groups;
        $session = JFactory::getSession();

The above code works fine as in, it checks the session if its active then lets the user work on external PHP app. The problem is that if I am not using the main Joomla site and am only working on the external PHP application, the session on the main joomla website expires hence leading to the logout on the external php application.

My Question is, how do I manage sessions between both the external and the main Joomla site?

I am sorry for the long post . I would really appreciate any help on this.

Many Thanks, Teju

  • Hi, I would really appreciate any suggestion on this please. Have been trying all sorts of different ways.
    – Teju Desai
    Jul 24, 2017 at 6:52

1 Answer 1


Just keep the session alive by pinging Joomla via JS:


    var xhttp = new XMLHttpRequest();
    xhttp.open('get', 'https://yourdomain.tld/index.php', true);

  • Ok , so this javascript file will be included for all the the perl/php scripts. Why didn't i think of this.... <br> I will try and let you know .Thanks Teju.
    – Teju Desai
    Aug 7, 2017 at 10:03
  • You can test it by setting the session time to 1 in the Joomla global configuration. Later change the time interval in the script closer to your real session time to save performance. Aug 7, 2017 at 10:07
  • If this was the correct answer to you problem, please mark my answer as correct. Thank you! Aug 8, 2017 at 13:36
  • Sorry, I had been away. I am just testing the solution now. I would do the required after i have finished testing.
    – Teju Desai
    Aug 16, 2017 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.