I have just written this exact thing using JanRain and Zend Framework, also done it with Facebook.
- You should create a normal registration system which uses a username, email and password. And implement some sort of Stay Logged In functionality on your log in form using a cookie to persist a token, as well as normal Session based login.
- Then create your Google log in link, which links to a script which talks to
https://www.google.com/accounts/o8/id
using JanRain OpenId.
- From the response you get from Google you can get their first name, last name and email, use this to populate the user table as you would with a normal registered user. But in this instance their username and password would be NULL. When this user is then in the table set up your Stay Logged In cookie.
- Now when the Google user returns they are already logged in using your normal Stay Logged In functionality.
- Your Log Out page should clear the session and remove the Stay Logged In cookie token.
You may want to consider what happens when someone logs in using Google, then logs out and then logs back in using Google at a later date. You will need to check for that user in the user table and match the user row up with the result from Google, rather than registering a new user each time.