Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm using Google OAUTH2 for my website. I can successfully login using the google authentication.

Here is what I want to do is: 1) user goes to website homepage and user signs in by clicking "sign in with google" and login is successful and user is taken to logged user dashboard page. 2) user comes back after half hour, user goes to home page and they should get automatically redirected to logged in user dashboard instead of homepage since they already have a valid session.

question - how can you detect if the user is already logged in? Should I be storing the access_token in the session to detect this? what's the recommended way to acheive this with Google OAUTH2?

share|improve this question
add comment

1 Answer

Yes, you can store the access token in the session, but keep in mind that it could be expired. You should be able to get a new one with an immediate request.

You could also try and do session synchronization from JavaScript, if your site does not have its own session management: https://developers.google.com/+https://waybackassets.bk21.net/api/javascript#gapiauthchecksessionstatesessionparams_callback

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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