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"] = "";
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.