Facebook login and registration on Yii

[font="Tahoma"]Hi everyone!

I am building a web app on Yii and I need to enable login and registration with Facebook. I looked over some topics on this forum but I couldn’t find a complete working solution.

This is the workflow I need in my app:

  1. user clicks login button

  2. he has 2 alternatives, logging in with Facebook or with an username and password (normal account).

  3. if he click ‘login with facebook’ button, the app gets its user_id from facebook and if he has an account on the app, he is logged in. If not, the app creates an account based on its facebook info.

I was thinking to use the new registration tool provided by facebook, also. The system I want to create is similar to the registration system used by Scribd.com.

Can someone help me? Thank you![/font]

Ive developed something similar , when you login with facebook its same you was logged in by CUserIdentity and when you call Yii::app()->user->id, will show you facebook id or Yii::app()->user->name will show you facebook name,this is still dev version but works fine, i will add more extra figures like permissions and define all states to be available to call from CWebUser without a extra fb db table. Currently don`t have time but i will update this .


I have tried your extension but it happens to be a problem with the cookie or something. Thanks anyway and hope to update your extension soon!

What I’m looking for is a full system working with a database that provides facebook connect login method.

I think that saying a little bit more than just seems to be a problem with cookie or something would help Igor or someone else to bring you some more help! :]

Can’t understand what database has to say in your case? As Igor already explained you, facebook connect (or any other similar solution - like OpenID) is only a way or method to authenticate user. It has nothing to do with database. It can be used in applications that doesn’t utilize DB at all. Please, provide more details, so we can at least try to help you.

I explained in my first post what I want. In other words, I want to use facebook data for accounts, still offering the possibility of login/registration by a form. It’s my first time working with a PHP framework and also my first time working with facebook connect. Hope I made myself enough clear.

Forgive me for not understanding you first time! :]

Sorry, but I can’t help you much here! :[ I’m pretty sure that if you want to offer your users login via Facebook Connect (or OpenID or other similar medium) as alternative to your main registration/login system, then you should rather look for a help in a documentation for FBC or OpenID. There should be and probably is a chapter there about integrating their tools into your website.

Beside this, you should implement a standard authentication/authorisation system as it is shown in the example of Blog Demo and described in detail in official documentation to Yii. Then you should plan, how you will integrate your DB with existing standard users with those, you allow to login through FBC / OpenID etc. Because, I assume that your users logging in from Facebook should also have something like account, settings etc. just like your normal users. Therefore - you are right - you have to implement some DB solution to store these additional users in the same or similar table.

I’m pretty sure, this is possible with Yii, but I don’t know if anyone did it before? Try to look in extensions or search through this forum. There are many occurrences that Facebook appeared in both, but I’m unsure if in context of logging in with FB account. Sorry again, that I can’t offer more help.

its not problem with the cookie , problem is with logout url now its non clickable but i will update this extension as i say but currently don`t have time, i will develop 2 versions one is with database other is without database.

I wish to everyone happy new year :)

Same to you, Igor and we’re waiting for your superb extension! :] Cheers! ;]

Have you tried Gigya login service (wiki.gigya.com)? It offers login via sever well-known providers. The procedure is really simple and they have good wiki. I’ve used it to implement alternative login and it works just fine.

Thanks mariodig, this would be an alternative. I would prefere a PHP solution though.

Well, this is just a few lines of javascript code you have to include. Then you handle the registration/login in your php code.

And is it free?

You can not use it on commercial sites. But its free to get an API key and try it out at least.

There is a yii extension called hybridauth that implements HybridAuth to enable social logins (Facebook, Yahoo, Twitter etc) for Yii.


  • hybridauth extension

  • hybridauth support forum

  • HybridAuth library

Hello there did you find the solution ? Am also having the similar challenge.
Am at the point where am able to save the user details in the db but the challenge is how do i save the password iof my facebook account to my database .This is the case assume you signing up with facebook