Multiple namespaces in web application
I've noticed that Management portal somehow manages to allow a single user to be in different namespaces in different tabs in the same application (i.e. Management Portal). I've looked at my Processes, however, and see that all of my processes using MgmtPortal think I'm in %SYS, even though 2 of them are looking at globals in two different namespaces; NamespaceA and NamespaceB.
I can even fool MgmtPortal because the first time I try to look at a global in NamespaceA it thinks I'm in %SYS! After a refresh, however, I can see the global in NamespaceA.
How does MgmtPortal do this? This is what I'm trying to achieve with my own web application (hopefully minus the fooling). GroupById doesn't seem to work (I have a separate web application for each namespace, and a different GroupById for each web application -- didn't seem to allow more than one namespace for one user).
I don't want to use CSPShare, as it comes with all sorts of warnings. I'm thinking of a Login cookie, but don't know how to do that yet.
IS programmers: does MgmtPortal do this programmatically? Is there a check in the code that keeps the display and the namespace in sync?