Integrate Elgg into an existing PHP application

Hi,
I am new to Elgg. I am trying to integrate Elgg into my existing PHP application. Both application(Elgg and existing app) will be hosted in the same server under same root folder. I am planning to use existing application as master and Elgg as slave. User validation and registration will be done through existing app as it is being done now. A link will be provided for Elgg in the menu of existing app. I am looking for best possible ways to:

1. open Elgg app from existing app via link. I wrote a new login plugin to unregister current login action and use new login event to read username from session variable saved by existing app. But Elgg is not recognizing the session value stored by existing app. Don't know what is the problem. I guess, I have use same session for both app. Is there any easy way to access session used by Elgg from existing app and set values to be used by new login event?

2. load user into Elgg database from external app when new user account is created(currently I am loading users onto Elgg database manually using the upload_user plugin)
Hope someone please help me. Thank you.

  • If you load the elgg engine into your external application, you can use all the Elgg API's inside your external application. This way you can auto login the user into elgg, create new elgg account when the user registers etc..

  • Webgalli - thanks for prompt response. How do I load elgg engine into my external application?

  • require_once("path/to/elgg/engine/start.php");

  • Thank you Webgalli. Will try your suggestion today.

  • By adding elgg engine into my external application, I am able to sucessfully call Elgg functions. But when I call Elgg functions, it is killing external application's session values. Not sure why calling Elgg functions is killing my external app's session. Do I have to use same seesion_name between external app and Elgg?

  • I'm having the same problem with the session values. Trying to incorporate a property site into elgg. I have tried same session name also without any luck. And also with different names.

    Btw. Sessions work on a different hostname on the same server, for the property part of the site. So it is something Elgg does with the session variables that seems to be causing this.

  • Pawel - I tried plugin route also. Unfortunately I couldn't make it to work. I wrote a new login action plugin which un-registered existing login action and used my new login plugin to login user. Unfortunately, I couldn't make the plug-in to read the session values set by external app. I am using session to pass username to Elgg. I don't want to pass username via url to Elgg for security reasons. Since Elgg is a sub-directory under my external app, I thought I will be able to read sessions variables set by parent app but somehow I am not able to get it work.

    Any help would be appreciated.

  • Elgg uses DB for session storage. If you want to use sessions in both apps, you need to handle them in the same way. One way is to run external app logic on system boot event (assuming that you want to do inclusion of elgg). Other option is to register the same session handlers for app as for elgg.

    That has nothing to do with registering actions.

     

  • Pawel - can you please give me more details about how to add external app logic on system boot event or direct me to any document available online. I appreciate your help! 

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking