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;
array_splice($rootFolder,-$currentfolderlevel);
$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 );
define('JPATH_BASE',implode(DS,$rootFolder));
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');
$mainframe->initialise();
$user =JFactory::getUser();
$session = JFactory::getSession();
//$groups = $options['user']->groups;
$session = JFactory::getSession();
$sessionState=$session->getState();
$sessionExpiry=$session->getName();
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