0

We have an external login system which creates set of cookies. My joomla site and external site (which is responsible to login a user) are on the same domain so I can access the cookies being set by external site. I want to login user automatically using those cookies in Joomla if user exists and if user doesn't exists, I want to create a user and log them in automatically.

Can someone please point me in a right direction what plugin to use so that it is a seamless experience to a user and user will never realize that they are being authenticated in some other system and logged in automatically?

If someone has done it before, and post the code snippet, that will be very helpful so that I don't have to re-invent the wheel

Thanks.

0

You have to create an "authentication" plugin to read cookies and auto-login the user.

You can simply duplicate and modify any of the "authentication" plugins.

Ref: Creating an Authentication Plugin for Joomla

  • Well, onAuthenticate will not trigger on page load. Will it? As I mentioned, user logged in to some other part of my domain. So I will have to start from cookies as soon as they land on my joomla site – Andy Johnson Feb 26 '16 at 16:03
  • You have to follow the regular login workflow... though you can customize the login form to auto-submit in the first visit to trigger onAuthenticate. If it works Ok, you can proceed. Otherwise, you should follow with the rest of auth plugins and in the worst case return and show the standard login form. – Anibal Feb 26 '16 at 19:50
  • 1
    Anibal's answer is halfway there. You need 2 plugins, authentication and system. The most appropriate plugin to fork (base your work on) would be the Cookie Authentication (formerly: Remember Me) plugin found under plugins/authentication/cookie. You only need to implement the onUserAuthenticate method in your plugin. You will also need to use a system plugin, just like the plugins/system/remember plugin to apply the authentication onAfterInitialise. – nikosdion Apr 28 '18 at 12:36
  • Hi, Can you provide the sample code this. – Raj Mohan Jul 17 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.