Implement facebook login

I need to implement a facebook login system in my site.
I have read the documentation of facebook api and seems relatively easy.

My problem is: i have many tables in my db that are related to the users table.
Let´s say i have a blog_post table and a user logged in with is facebook account creates a new post. What should i put in the user_id field of posts table?

Should I,when the user log in for the first time with his facebook account, get his profile data and insert into my users table? Or should I use its facebook userId (But that would break my foreign keys).

In resume, my problem is, how to relate FB logged in user with my application data and database tables which needs to store the user id.

Yes. That was my idea.

You always want to “own” your user data. And, in the future, you might want to use a different single sign-on system. So you should keep your current user data and just attach the Facebook ids to it when you authenticate someone.

Hi Popovich,
I believe you implement the Facebook connect login system. Friend Do you
can give a sample idea How it can do in case of User Table level. If you
can give a sample code for same implementation it’s really a good job. I am
waiting your reply

Anes :slight_smile: