0

I have two projects running on same server(localhost). one project is in joomla and the other in php which also need to be executed with in joomla.

  1. Can i have a single login for both the projects ?
  2. Can i share username and password of joomla with other project

If i can, how can i do that

Any advice is much appreciated Thanks

Harsha
  • 33
  • 9
  • possible duplicate: http://stackoverflow.com/questions/10750402/single-sign-on-for-joomla-admin-and-frontend – jogesh_pi Mar 17 '14 at 05:15
  • thanks for the reply but that is not what i wanted. i need password sharing between two projects not frontend and backend – Harsha Mar 17 '14 at 05:21
  • then what it means in your question? `Can i have a single login for both the users ? ` – jogesh_pi Mar 17 '14 at 05:22
  • is your **Other Project** is in Joomla? or in Core PHP? – jogesh_pi Mar 17 '14 at 05:24
  • it is in core php. sorry i meant both projects – Harsha Mar 17 '14 at 05:29
  • sharing only password not works, take a look on the joomla's users table, it store the encrypted password, so if you want to share single password then you must have the same algorithm to encrypt and for decrypt the password in your core php project. – jogesh_pi Mar 17 '14 at 05:36
  • can i make the session of user in joomla to be available for both the projects – Harsha Mar 17 '14 at 05:41
  • this is how you can achieve it with session. http://stackoverflow.com/questions/13806701/secure-and-flexible-cross-domain-sessions#answer-13807080 – jogesh_pi Mar 17 '14 at 05:44
  • The simplest thing is to make a standalone Joomla application that gets the Joomla config information for the database and which can also use the API to manager the passwords and authentication. If you make it a web app you can share the session between the two applications. – Elin Mar 17 '14 at 05:44
  • I don't want to use another form in php project to login. I just need username and id of joomla user in php project so that i can get the corresponding details of the user – Harsha Mar 17 '14 at 06:41

1 Answers1

0

Yes you can have single login for both Joomla project and you core php project.

This can be done by creating a user plugin that is called on login and if successful the authenticated account details can be passed to other project via http request, rest or via a database stored variables.

Heare is demostration using a http return link;

 <?php
 class plgUserPLUGINNAME extends JPlugin {
 onUserLogin($user, $option){
    $application = JFactory::getApplication();
    if($user['id']){
      $return = JRequest::getVar('return');
      $application->setRedirect($return);
      return true;
    }else{
      return false;
    }

 }
 onUserLogout($credentials){
     $application = JFactory::getApplication();
     $return = JRequest::getVar('return');
     $application->setRedirect($return);
     return true;    
 } 
?>

Note You will access the login within joomla and redirect will happen based on return url.

To call the page from core php project

<?php
   $token = rand(0,100);
   $_SESSION['login_token'] = $token;
   $return = 'www.corephpproject.com/loggedin.php&token=$token';
?>
<a href="www.yourjoomlasite.com?option=com_users&view=login&return="<?php echo $return; ?>>Login</a>

To call from joomla you will us joomla menu links and modules.

Dedan Irungu
  • 61
  • 2
  • 6