Same name and namespace in other branches
  1. 5.x includes/bootstrap.inc \drupal_anonymous_user()
  2. 7.x includes/bootstrap.inc \drupal_anonymous_user()

Generates a default anonymous $user object.

Return value

Object - the user object.

2 calls to drupal_anonymous_user()
sess_read in includes/session.inc
Reads an entire session from the database (internal use only).
user_logout in modules/user/user.pages.inc
Menu callback; logs the current user out, and redirects to the home page.

File

includes/bootstrap.inc, line 1093
Functions that need to be loaded on every Drupal request.

Code

function drupal_anonymous_user($session = '') {
  $user = new stdClass();
  $user->uid = 0;
  $user->hostname = ip_address();
  $user->roles = array();
  $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
  $user->session = $session;
  $user->cache = 0;
  return $user;
}