简体   繁体   中英

integrating my own joomla login to main site

I am trying to make my own login form to extend more field information. I try to build it separate from my my site, so I save it to testlogin.php in base Joomla main site directory. Here is my script:

<?php
 define('_JEXEC', 1 );
 define ('JPATH_BASE', dirname(_FILE_));
 define('DS',DIRECTORY_SEPARATOR);
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');


$mainframe =& JFactory::getApplication('site');
$mainframe ->initialise();

$credentials=Array('username' => 'dadanuser', 'password' => 'dadan');
$options=Array('remember' => true);

$mainframe->login($credentials, $options); 
//echo $result;
$user =& JFactory::getUser();
echo $user->username;

$session =& JFactory::getSession();
$myUser = $session->set( 'myUser', $user );
?>

I run it directly and I get login with username: dadanuser, but when I open Joomla main site I still not login yet, maybe I have to set session in right way?

anyone can help ?

Why reinvent the wheel? If you are in 2.5 or 3 you can just use a profile plugin to add the extra fields. If you are in 1.5 you can use the earlier version of that which was distributed as an extension. http://joomlacode.org/gf/project/usermeta

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM