0
我需要創建一個系統插件(無auth插件!),其中登錄到前端automaticaly的用戶也會在後端登錄。 (用戶有權通過管理員登錄到後端)用戶登錄到前端 - 插件自動登錄到後端
我嘗試通過下面看到的非常基本的代碼來做到,結果是肯定的,但如果我轉到後端,用戶仍然需要登錄。
在會話表中設置了後端會話行,但「guest」字段設置爲1而不是0,並且用戶標識設置爲0而不是正確的標識。
這怎麼辦?
function onAfterInitialise() {
if(JFactory::getUser()->get('id')) { // logged in?
$credentials = array();
$credentials['username'] = "walter"; // hardcoded first
$credentials['password'] = "123"; // hardcoded first
$options = array();
$options['action'] = 'core.login.admin';
$result = $app->login($credentials, $options); // this seams to work
if (!($result instanceof Exception)) {
$app->redirect("www.bummer.de");
}
}
我已經用JFactory :: getApplication('administrator')調用進行了測試。仍然沒有創建後端會話。 – Mike