2017-02-02 26 views
1

嗨,我讓我的應用程序,這是從一個Joomla應用程序的iframe投放並且獲得了從的Joomla會話的用戶的詳細信息,下面的錯誤信息:的Joomla工廠獲得用戶

警告:函數ini_set():會話處於活動狀態。你不能在這個時候 第45行上的ID更改會話 模塊的INI設置/home/sites/accstats.co.uk/public_html/libraries/joomla/session/handler/joomla.php :973

這是我使用的代碼,它一直適用於舊版本的joomla,我不是開發者(只是一個業餘愛好者),所以我不確定問題是什麼。

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"] = ""; 
} 
+0

你檢查了session.autostart嗎? http://stackoverflow.com/questions/32814895/message-ini-set-a-session-is-active-you-cannot-change-the-session-modules和http://stackoverflow.com/questions/13539269/ errorexception-warning-ini-set-a-session-is-active-you-can-change-the-s?你使用的mod-spdy模塊http://stackoverflow.com/questions/13654848/php-warning-a-session-is-active-you-cannot-change-the-session-modules-ini-set?如果您在文件的開頭添加會話開始會發生什麼情況? –

+0

首先,你不需要我們。 DS。在大多數情況下,因爲Windows不再有處理問題* nix斜線。但是第二個..它在我看來就像是你有一個雙斜線,因爲你在JPATH_BASE結尾處有一個斜線,然後在追加下一個段之前有一個'.DS.'。 – Elin

回答

0

我有同樣的問題。當我搬到現場服務器時,我的AJAX文件都沒有工作。花了幾個小時後,我發現這是一個URL問題。所以通過更正JPATH_BASE來解決這個問題。我看到你已經給出了該參數的絕對路徑。你爲什麼不把它定義是這樣的:

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

如果它不爲你工作,你可以在代碼行2.更改斜槓的數量我複製並粘貼我有應用程序的頭問題與解決它。希望它也適用於你。

相關問題