1
votes

Hi I am getting the following error message on my application, which is running in an iframe from a joomla application and getting the user details from joomla session:

Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /home/sites/accstats.co.uk/public_html/libraries/joomla/session/handler/joomla.php on line 45 id:973

This is the code I am using, which has always worked fine for older versions of joomla, I am not a developer (just an amateur) so am unsure what the problem is.

define( '_JEXEC', 1 );
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', "/home/sites/accstats.co.uk/public_html/" );

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();

if($user->id)


// log in
{
        $_SESSION["UserID"] = $user->get("username");
        $groups = $user->get('groups');
        $_SESSION["GroupID"] = reset($groups);
        $_SESSION["UserName"] = $user->get("name");
        if ($user->get('isRoot')) $_SESSION["AccessLevel"] = ACCESS_LEVEL_ADMINGROUP;
        else $_SESSION["AccessLevel"] = ACCESS_LEVEL_USER;
}
else 
// log out
{
        $_SESSION["UserID"] = "";
        $_SESSION["AccessLevel"] = "";
        $_SESSION["GroupID"] = "";
        $_SESSION["UserName"] = "";
}
1
Did you check session.autostart? stackoverflow.com/questions/32814895/… and stackoverflow.com/questions/13539269/… ? are you using mod-spdy module stackoverflow.com/questions/13654848/… ? what happens if you add a session start at the beginning of the file?Riccardo Zorn
First, you don't need to us . DS . anymore in most cases since Windows no longer has a problem handling *nix slashes. But second .. it looks to me like you have a double slash because you have a slash at the end of JPATH_BASE and then a .DS. before appending the next segment.Elin

1 Answers

0
votes

I had the same problem. When I moved to live server none of my AJAX files worked. After spending hours on it, I found that it's a URL problem. So figured it out by correcting the JPATH_BASE. I see you've given the absolute path to that parameter. Why don't you define it this way:

define( '_JEXEC', 1 );

define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../../..' ));

// including the main joomla files
require_once ( JPATH_BASE . '/includes/defines.php' );
require_once (  JPATH_BASE . '/includes/framework.php' );
require_once (  JPATH_BASE . '/configuration.php' );

// Creating an app instance
$app = JFactory::getApplication('site');
$app->initialise();
jimport( 'joomla.user.user' );
jimport( 'joomla.user.helper' );

If it didn't work for you, you can change the number of slashes at code line 2. I copied and pasted the header of the application that I had the problem with and resolved it. Hope it works for you too.