Login from external site

Hello there,

as title says, i need to log in elgg from an external site and i need to use this external site's login form.

I got webservices working for other purposes but using webservices for login don't work since it uses Sessions which is logical. am i right?

I'm already using webservices to register the user into elgg when he registers into my external site, so he uses same credentials for both sites and register only once.

Then, i'd like to make a plugin exposing a function just like webservices would, to login using the same credentials as my external site's login. Something like 'function login($username, $password, $persistent)' that i could put into the action file following the external site's login form.

Can i do that using AJAX? and how ? maybe there's another way?

If this project is a success i'll publish the plugin asap.

Anyway, i love this community, i got so much done from all the brainstorming happening here. Thank you.

  • I think i found a way, still using curl.

    Elgg stores sessions data in database and uses cookies to pair the user with this data. It's not working because CURL can't directly store Cookies.

    So I need my login function to return cookies codes ('Elgg', 'elggperm',...) and then set them manually.

    how can i get these cookies codes/session from elgg?

  • Ok curl does actually store cookies. But since im calling the login from another domain, it sets cookies to this domain and not to elgg's domain.

    Here is a screenshot of what i got in my cookies in firefox:



    files.odbi.fr is the domain from which i call my login webservice function.

    testcommunaute.odbi.fr is the elgg domain.

    As you can see, when i call my login function, it stores cookies for files.odbi.fr instead of testcommunaute.odbi.fr. How can i get these cookies and repuplish them to the good host: testcommunaute.odbi.fr?

    Anyway i don't think these are enough to actually log the user in because, as you can see on the screenshot, when i perform a normal login on testcommunaute.odbi.fr i get 1 more token: 'Elgg'. (and a second: 'elggperm' if i check the 'remember me' checkbox)

    I've read that you can login using only elggperm cookie but i'm a bit lost with all these cookies. Can't understand what they stand for and which ones are needed to login. And how do i republish cookies stored for files.odbi.fr into testcommunaute.odbi.fr?

  • If both applications are under the same domain, you can write a cookie whenever the user logins to your main application. Elgg can then read the cookie, identify the user and log them in.


  • Thx for the help Ismayil i'll do that.

    But how can i write that cookie? I mean how can i get the data to put in it? And which cookies are needed?


     I want to display the join group button on external site I am new in elgg programming plz help me with the.code 
    Thnx in advance.

  • Hello Everyone, I am using elgg 1.9 and I have my own php system which have it's own login form. I want my login form to log in to both my system as well as elgg 1.9

    If anyone can help me please?

    [Moderator: this comment was off-topic. It was moved to its own topic.]

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