Drupal: Storing data in the user profile

If you want to store data in the user profile, here’s an example of a quick and dirty way to do it:

global $user;
if ($user) {
  $array = array('fieldname' => 'value_to_save');
  user_save($user, $array);
}

Then access it with $user->fieldname. For more configurability, check out the Profile module.