Return to Snippet

Revision: 35177
at November 3, 2010 22:48 by joseduenas


Initial Code
<?php
//http://domain.com/script/script.php?username=username&passwd=password

define( '_JEXEC', 1 );
define('JPATH_BASE', '../' );
define( 'DS', DIRECTORY_SEPARATOR );
require_once('../configuration.php');
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );

/* Create the Application */
$mainframe =& JFactory::getApplication('site');
jimport('joomla.plugin.helper');

$credentials = array();
$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
$credentials['password'] = JRequest::getVar('passwd', '', 'method', 'passwd');

//preform the login action
$error = $mainframe->login($credentials);
$user = JFactory::getUser();
//now you are log in

$mainframe->logout();
//now you are log out

Initial URL
http://stackoverflow.com/questions/2075335/how-to-log-into-joomla-through-an-external-script

Initial Description


Initial Title
Login en Joomla desde una script externo

Initial Tags
login, php, joomla

Initial Language
PHP