I want to make a script which will login the user into Joomla and there isn't any official documentation on how to this at http://api.joomla.org/Joomla-Platform/User/JAuthentication.html
Asked
Active
Viewed 1,209 times
0
-
Think this might help http://stackoverflow.com/questions/2176595/joomla-login-authentication-from-external-app – Lodder May 25 '12 at 18:31
1 Answers
0
I had a similar issue with someone who requested me to login in a Joomla 2.5 website from an external custom HTML form. I'm a begginer in this matter, but I found a quite helpful script, since it works right the way I needed (all the credits for this web site).
I don't use the JAuthentication class, but the JFactory::getApplication object and its login method to authenticate to Joomla:
<?
if(isset($_POST['Submit'])){
define('_JEXEC', 1 );
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', dirname(__FILE__));
require_once (JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once (JPATH_BASE .DS.'includes'.DS.'framework.php' );
$app =& JFactory::getApplication('site');
$app->initialise();
//echo "<br>";print_r($app);
$credentials = array();
$credentials['username'] = $_POST['username'];
$credentials['password'] = $_POST['password'];
//echo "<br>Login res: ".$app->login($credentials);
if($app->login($credentials) == 1)
header('location: http://www.johnabril.com/seguro_desmp');
}
?>
As you can see, you just have to send an username and password strings from your HTML form, and it's done.
Hope it helps.

Icarus87
- 1