[development] global $user unavaialable?

Moshe Weitzman weitzman at tejasa.com
Fri Mar 20 18:30:05 UTC 2009


that snippit tests if the user is logged in, not if $user is
populated. you could have a full anonymous $user object.

the basic loading of a $user gets triggerred by session_start() but if
you have to call that on your own you are way off the beaten path in
Drupal and really need to grok whats happenning step by step in order
to assure security and code sanity. that gives a basic $user object.
If you need it call, you might have to call user_load() yourself.

On Fri, Mar 20, 2009 at 2:02 PM, David Metzler <metzlerd at metzlerd.com> wrote:
> I'm working on implementing a new cas_server module that allows drupal
> accounts to be used as a single - sign on source.  I have a drupal 5 site
> issues a redirect to a drupal 6 site, and when I redirect to that page I
> don't find that the $user global is populated.  Is there some function or
> include that I should b calling to make sure that this data is there?
>
> Code snippet that isn't returning correct data.
>
> global $user
> if ($user->uid) {
>  drupal_set_message('user logged in');
> }
> else {
>  drupal_set_message('User not logged in');
> }
>
> Note that if I click on any other link in the drupal page.  I show as being
> logged in, but the redirect to this page does not load the $user variable.
>
> Developing against drupal 6.10
>
>


More information about the development mailing list