Why would $user->sid be undefined? I added some debugging statements (using dd()) which include a timestamp and $user->sid (after declaring $user as a global).  I tested it, of course, and everything worked great for me. Then a user reported getting some notices which said "Undefined property: stdClass::$sid ..."

I added a conditional to test to see if $user->sid is set before writing out the value, but I didn't think that it was possible for it to not be set!  I did some quick Google and drupal.stackexchange.com searches, but couldn't find any info on how this might be possible.  

Anybody have any insight here?

TIA,
Lee
If you are not logged in the property will be undefined. This is all I've got for the anonymous user

object(stdClass)#7 (4) {
  ["uid"]=&gt;
  int(0)
  ["hostname"]=&gt;
  string(9) "XXX.XXX.XXX.XXX"
  ["roles"]=&gt;
  array(1) {
    [1]=&gt;
    string(14) "anonymous user"
  }
  ["cache"]=&gt;
  int(0)
}