PHP 5 has reached end of support and will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy PHP 5
applications, even if your organization previously used an organization policy to
re-enable deployments of legacy runtimes. Your existing PHP
5 applications will continue to run and receive traffic after theirdeprecation date. We recommend that
youmigrate to the latest supported version of PHP.
User ObjectsStay organized with collectionsSave and categorize content based on your preferences.
An instance of theUserclass represents a user. User instances are unique and comparable. If two instances are equal, then they represent the same user.
The application can access the User instance for the current user by calling theUserService::getCurrentUser()function.
use google\appengine\api\users\UserService;
$user = UserService::getCurrentUser();if (isset($user)) {return sprintf('Welcome, %s! (<a href="%s">sign out</a>)',$user->getNickname(),UserService::createLogoutUrl('/'));} else {return sprintf('<a href="%s">Sign in or register</a>',UserService::createLoginUrl('/'));}
You can use theUserService::getCurrentUser()function no matter which authentication option your app uses.
A User instance can be also constructed from an email address:
$user = new User('Albert.Johnson@example.com');
If theUser::__construct()is called with an email address that does not correspond with a valid Google account, the object will be created but it will not correspond with a real Google account. This will be the case even if someone creates a Google account with the given email address after the object is stored. A User value with an email address that does not represent a Google account at the time it is created will never match a User value that represents a real user.
The User object for a valid user can provide a unique ID value for the user that stays the same even if the user changes her email address. ThegetUserId()method returns this ID, astringvalue.
The User object has the same form no matter which method of authentication your app uses.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-12-15 UTC."],[],[]]