I just wrote this exact thing using JanRain and Zend Framework, also did it using Facebook.
- You should create a regular registration system that uses a username, email address and password. And implement some βStay logged inβ function in the form of logging in using a cookie to save the token, as well as for a regular login based on the session.
- Then create your google login link that links to a script that talks to
https://www.google.com/accounts/o8/id using the JanRain OpenId function. - From the response you receive from Google, you can get your first name, last name and email address, using this to fill out the user table in the same way as with a regular registered user. But in this case, their username and password will be NULL. When this user is in the table, set the Stay Logged In cookie.
- Now that the Google user is back, they are already logged in using your usual login features.
- On the Logout page, you must clear the session and remove the Save Log token.
You might want to think about what happens when someone logs in with Google, then logs out and then logs in again with Google. You will need to check this user in the user table and match the user string with the Google result, and not register a new user each time.
source share