Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 1944

General Questions/New to Joomla! 5.x • Login from external code

$
0
0
This code works perfect on Joomla 4:

Code:

if ($_SERVER['REQUEST_METHOD'] === 'POST') {        $username = $input->get("username", null, "string");$referer = $input->get("referer", base64_encode("./"), "string");$password = $input->get("password", null, "string");        //...$app = Factory::getApplication();if (!$response){$sess->set("adm_message", "Usuario o contraseña incorrectos");}else{try {$app = Factory::getApplication('site');jimport('joomla.plugin.helper');$credentials = array();$credentials['username'] = $username;$credentials['password'] = $password;$app->login($credentials);$user = Factory::getUser();}catch (Exception $e) {echo $e->getMessage();}}        $app->redirect(base64_decode($referer));exit;}
But on Joomla 5 is not working and i get the following error:

Attempted to load class "Joomla" from namespace "Joomla\Plugin\User\Joomla\Extension".
Did you forget a "use" statement for another namespace?

$response is true, the problem is when i try to login the user.

Statistics: Posted by BENKENOBI — Wed May 22, 2024 4:29 pm



Viewing all articles
Browse latest Browse all 1944

Trending Articles