Community & Support

Drupal switches user when viewing user profiles

When I view the profile of another user, it logs me out and logs me in as that user. I am wondering how this could even happen? I have some modules that call user_load to get specific data out of user profile, but I never overwrite the global $user object with it. Don't see how this could be happening?

Comments

Still not making headway on

Still not making headway on it... disabling modules one by one until the problem stops is not working :(

Anybody have any thoughts on

Anybody have any thoughts on this?

you're not giving much info.

you're not giving much info. e.g. "Some modules". Which modules? What happened when you disabled modules? Should be no premanent change to site unless you uninstall them.

The only thing I know of that logs in as another user the devel module that has a "switch user" block.

I do have the devel module

I do have the devel module installed - but I thought you would have to explicitly switch a user - it shouldn't switch while viewing their user profile? I have several other custom modules, and disabling those does not remedy the problem. I suppose it could be the devel module, I have yet to disable that one for the time being.

As I understand, this problem is 99.9999% related to calling user_load(...) and overwriting the $user variable - I can guarantee that none of my modules do this.

"I suppose it could be the

"I suppose it could be the devel module, I have yet to disable that one for the time being."

And why are you unwilling to try this?

And what are you clicking on to view a profile? What URL show up in the browser when you hover over the link?

Disabling the devel module

Disabling the devel module did not fix, completely removing it also did not fix.

When I click "My Profile" it is correct (/user/1) - when I put /user/2 into the address bar to view somebody elses profile, I am still logged in as uid 1. When I click "My Profile" again (still /user/1), it switches the user, and the "My Profile" link becomes /user/2 for example.

Also, I have not disabled any of my modules because I don't even call the user_load function, nor do I mess with the user object at all... I suppose I could try but there's things in the profile template tied into my modules (functions that are called) that will render the profile unviewable and unwinding that will take a lot of time - not unwilling to do it, just haven't.

And what happens when you

And what happens when you diable your modules? That's the most likely problem. Just insisting that your module is not the problem does not make it so. Disable them and see if the problem still happens.

Disabling my modules did not

Disabling my modules did not solve the problem. Other modules I have installed:

Actions - disabled, didn't fix

Blog - disabled, didn't fix
Color
Contact - disabled, didn't fix
Help - disabled, didn't fix
Menu - disabled, didn't fix
Profile - disabled, didn't fix
Search - disabled, didn't fix
Taxonomy - disabled, didn't fix

All Core - required

Devel - disabled, didn't fix
Helpers
Helpers_database
Helpers_form
Helpers_node
Helpers_theme

Image
Image assist

Nodequeue

Archive
autologout
checkbox Validate
Contact Forms
Email Registration
Frequently Asked Questions
Faq_Ask
IMCE - disabled, didn't fix
Legal - disabled, didn't fix
Custom1 - disabled, didn't fix
Custom2 - disabled, didn't fix
Custom3 - disabled, didn't fix
Custom4 - disabled, didn't fix

jQuery Update
Views
Views Theme Wizard
Views UI

Workflow
Workflow access

That's pretty odd. Did you

That's pretty odd. Did you made any changes to the core drupal files? You might try putting in a fresh copy to see what happens.

When you say "viewing user profiles" you don't say how you're viewing them. If you go directly to yoursite/user/3 by entering the URL in the browser, does it change the currently logged in user to user 3?

No changes to drupal core

No changes to drupal core files - that is against the rules and why an API is provided :) Just for giggles I have replaced all core files and no change is present. If I go to mysite/user/3 i am still logged in as my user, but if I navigate away from their profile, I am then logged in as them.

What about PHP snippets? All

What about PHP snippets? All it takes is an accidental

if ($user->uid = $value) {}

instead of

if ($user->uid == $value) {}

and very strange things will happen

I've been pretty careful

I've been pretty careful about that - but not unheard of. I will have to spend some time "sifting" through the code, I will get back to you. Thanks for all the help thus far!

Well, that was hairy, but I

Well, that was hairy, but I got it. corrupted $user in a bootstrapped file outside of drupal that utilized jpgraph. Annoying! Thanks for the help!

I got the same problem.. What

I got the same problem.. What did you do to fix it?

I made sure nothing was

I made sure nothing was overwriting the global user object.. such as $user = user_load( ... ) <- that is bad.

I'm having the same problem.

Hi,

I have beenstruggling with this same issue. I would be glad if you could kindly explain a bit how to solve the problem.

Which files did you modify to get rid of this problem? What lines of code did you change?

Kind regards,
Tamasco