Logout Across Tabs

How to implement Logout Across Tabs in django automatically without refresh ?

Can you be more specific here? Logging out should invalidate the session cookie, and so other tabs should no longer be able to retrieve data.

Or are you hoping to actually have one tab cause the other tabs to refresh their pages? If so, then no - it would be a security problem to allow a tab to control or direct a tab it didn’t create.

1 Like

Thanks @KenWhitesell .

I need user will logout automatically in all tabs when logged out in one open tab of browser without page refresh.

Yes, other tabs no longer be able to retrieve data. But other tabs will be logged out and redirect to login page automatically.

Did you open Facebook in two tabs ? and logout in one tab ?

Thanks.

Facebook uses websockets to maintain a persistent connection between tabs and the server. It is not a situation of “tab A” logging out “tab B” - that’s not what’s happening there. Tab A is logging out, and Facebook then forces the logout on tab B through the websocket.

Yes, if you add Websockets and Channels to your application, you could do the same thing.

1 Like

Thanks @KenWhitesell . Could you please help me to implement this in my django application ?

Have you any tutorial regarding this ?

Thanks.

For basic Channels / Websocket usage, see Django Channels — Channels 4.1.0 documentation