Manual:$wgUser

Details
The User object encapsulates the state of the user viewing/using the site.

The User object can be queried for things like the user's settings, name, etc.

It handles the details of getting and saving to the "user" table of the database, and dealing with sessions and cookies.

Client classes use the  functions to access these fields.

These functions do all the work of determining whether the user is logged in, whether the requested option can be satisfied from cookies or whether a database query is needed.

Most of the settings needed for rendering normal pages are set in the session cookie to minimize use of the database.