http://qs321.pair.com?node_id=11102246

kikuchiyo has asked for the wisdom of the Perl Monks concerning the following question:

Hi.all;

I have a Dancer2 application for which I use the YAML session engine. Its purpose is to provide a simple GUI for certain system administration tasks at $work. The app is constructed so that the user first encounters a login page where he can enter his username and password, and the name of the server he wants to work on, and if the credentials are correct, the app displays the state of the various services running on the server and the actions available on them. (I'm deliberately vague here - the details are not really important.)

I use (abuse?) Dancer2's session mechanism to store all the relevant data from the server the user working on - and here is my problem. Dancer2's sessions are, in effect, per browser. So if the user opens my app on a browser tab, logs in to one server, then opens a second tab and attempts to log in to a different server, it won't work, because (at best) it will display the data from the existing session, or (at worst) behave in a confusing, incorrect way.

Is it possible to make the sessions per window (or more properly, per browser tab)? The closest example I've found is Dancer::Plugin::WindowSession, but that's an abandoned module for Dancer 1, apparently not ported to Dancer2.