Is global $user an array of userspecific value?

Is it also possible to add other session variables, such as $user_favorite_animal on one customized page, that can be called from another customized page?

Would it be better to POST the variables from page to page, or would it be better to insert and retrieve variable data from db tables?

Regards,
Scopas

Comments

nancydru’s picture

$user is an object variable.

I would store the variable using variable_set and variable_get (and don't forget variable_del).

Nancy W.
Drupal Cookbook (for New Drupallers)
Adding Hidden Design or How To notes in your database

dman’s picture

If you are looking at user-specific preferences, you are probably best to integrate with the existing profile module. User prefs defined there become available in the $user array (IIRC) or at least can easily be fetched from it.
Plus they can be maintained on the user page, indexed etc.

It does however work only for registered users. Dunno if it's appropriate for transient anon users.
For them, I guess just using $_SESSION is adequate. Drupal does funny built-in things with SESSION however, like serializing it to the database every page-load (which is currently killing a high-traffic sit for me) but the data is certainly available there.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/