Login en Joomla desde una script externo


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. //http://domain.com/script/script.php?username=username&passwd=password
  3.  
  4. define( '_JEXEC', 1 );
  5. define('JPATH_BASE', '../' );
  6. define( 'DS', DIRECTORY_SEPARATOR );
  7. require_once('../configuration.php');
  8. require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
  9. require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
  10. require_once ( JPATH_BASE .DS.'libraries'.DS.'joomla'.DS.'factory.php' );
  11.  
  12. /* Create the Application */
  13. $mainframe =& JFactory::getApplication('site');
  14. jimport('joomla.plugin.helper');
  15.  
  16. $credentials = array();
  17. $credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
  18. $credentials['password'] = JRequest::getVar('passwd', '', 'method', 'passwd');
  19.  
  20. //preform the login action
  21. $error = $mainframe->login($credentials);
  22. $user = JFactory::getUser();
  23. //now you are log in
  24.  
  25. $mainframe->logout();
  26. //now you are log out

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.