In this code sample, if the user is already signed in to your application, getCurrentUser()
returns the User object for the user. Otherwise, it returns null:
if ($user) {
echo 'Hello, ' . htmlspecialchars($user->getNickname());
}
If the user is not signed in, the browser redirects to the
Google account sign-in screen. The redirect includes the URL to this page
(through the inclusion of $_SERVER['REQUEST_URI']) so the Google account
sign-in mechanism will send the user back here after the user has signed in or
registered for a new account: