Jared Joke
Jared Joke

Reputation: 1356

Django user logged out when the page refreshes

It's really confusing me and I don't understand why. I have database backed sessions (with mongoengine) but it seems like when I visit a page then refresh it the user is no longer logged in. Essentially

request.user.is_authenticated() 

is False after the page reset

Anyone have any ideas? In my settings I have:

SESSION_ENGINE = 'mongoengine.django.sessions'

MIDDLEWARE_CLASSES = (
...
'django.contrib.sessions.middleware.SessionMiddleware',
...

On the debug page I notice a few things:

SESSION_COOKIE_DOMAIN   None  
SESSION_EXPIRE_AT_BROWSER_CLOSE  False
SESSION_COOKIE_AGE  1209600

Could the absent cookie domain be a clue as towards what the problem is?

Upvotes: 5

Views: 978

Answers (1)

йа йа
йа йа

Reputation: 1

I ran into the same problem and in the solution browser they wrote to me that samesite='None' and I can't save cookies.

Try to remove samesite = 'None'

Upvotes: 0

Related Questions