I have a custom module implementing hook_file_download() for both public and privately managed files. At the head of my hook implementation I have the typical declarations to access the $user global:
function contractor_file_download( $uri ) {
$caller = 'contractor_file_download';
global $user;
devlog( $caller.': uri is "'.$uri.'", user is "'.$user->uid.'"' );
devlog( $caller.': globals user is "'.print_r( $GLOBALS['user'], 1 ).'"' );
...
}
The problem I'm having is that $user contains the anonymous user sometimes, if that makes any sense. Although it makes no sense, when testing via an OSX machine, any browser, the $user is always the valid logged in user. But when testing via any flavor of Windows, about 70% of the time both $user and $GLOBALS['user'] both contain the anonymous user. Yet, in all instances, the "My Account" link can be clicked and the correct logged in user profile loads.
What could cause $user to contain the anonymous user even after the user has logged in?
Additional info: the files being accessed getting the anonymous user are all private managed files.