Is the Django request.user.is_authenticated method always TRUE (or can it be FALSE)?

Hello everyone.

The Django request.user.is_authenticated works fine in private browser windows (returns TRUE or FALSE depending on whether the user is registered), but in standard windows it always returns TRUE (as stated in the Django documentation).

Does anyone know why this happens?

Thanks

Hey,

AnonymousUser.is_authenticted is False, see django/django/contrib/auth/models.py at 337c641abb36b3c2501b14e1290b800831bb20ad · django/django · GitHub

request.user resolves to an instance of AnonymousUser if you’re not logged in.

You’re probably logged into the admin panel or something?

Welcome @cacaedu !

To perhaps add little to the previous answer, all Chrome, Firefox, and Edge windows each share session data among all instances (but not with each other).

In other words, if you’re logged on in Chrome in one window, you’re logged on in all windows. And, if you log out of one window, you will be logged out in all windows.

They all also treat “Incognito windows” the same way! If you open two “Incognito windows”, they will share the same session state.

So if you have all three browsers installed, you have six possible session states available - two (regular and private) for each of the three.