You can look at Encapsulated Tokens [0]. For this, the users must pre-exist on all the publish instances, if this is not possible, then you should use sticky connections. To close the session, you can use session.logout(), check [1]. [0]: https://docs.adobe.com/content/help/en/experience-manager-65/...