Multiple parallel sessions per user

If possible, how to implement/ how to approach custom middleware class, such that a user can have multiple active sessions in parallel.
The reason for having multiple sessions per user is that, each time a user opens the tool in a new browser tab, a new session needs to be created, by keeping the previous sessions running. Acorrdingly, multiple such sessions need to run in parallel in different browser tabs.

In the tool that we have, When accessing the tool in parallel with different queries, the data of access #2 got displayed in access #1 after switching. So, the data from the newest tab go displayed in the previously opened tab.

This is a browser issue, not a Django issue.

Chrome, for example, shares cookies among all tabs. There’s another set of shared cookies among all incognito sessions.

You would need to open up Chrome using a different profile for each session, or find some Chrome extension to do this.

Likewise, if you use Firefox, you’d need to do something similar.

This is not something that Django can change.

Hi,
Thank you very much for the quick response.
In our case, it is restricted to use chrome without installing any extensions because of company policy.

I got to know that, request.session.session_key is the unique identifier, according to which Django processes data and distinguishes between different requests, and the attribute session_key is stored in browser cookies.

May I know if there is any mechanism (probably using custom session middleware?) to create new session_key and corresponding session each time, a user request is generated (loading the app from new tab, or refreshing the tab).?

Thanks in advance for your kind help.

That makes no sense.

Keep in mind that all tabs share the same cookies.

If you change the session id in “Tab 2”, it’s also going to change the session id for “Tab 1”.

Basically, you’d be logging the user out of every tab with every request from any tab.

This is not a behavior that can be adjusted from the server. It can only be addressed from within the browser.