Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Dancer2 per-window sessions?

by afoken (Chancellor)
on Jul 01, 2019 at 17:55 UTC ( [id://11102260]=note: print w/replies, xml ) Need Help??


in reply to Dancer2 per-window sessions?

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, [...] 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.

Your problem is your login page. Dancer2's session's aren't per browser. They are per browser, server, and TCP port. If Dancer2 uses cookies for storing a session key (most likely it does), you can set the cookies for a subtree of the document tree. So if you construct your URLs to look like http://loginserver.example.com/session/littleserver/..., http://loginserver.example.com/session/bigserver/..., http://loginserver.example.com/session/otherserver/..., and so on, and set the cookies path to include the server name (i.e. /session/littleserver, /session/bigserver, ....), Dancer2 should not confuse the sessions.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Dancer2 per-window sessions?
by dsheroh (Monsignor) on Jul 02, 2019 at 08:00 UTC
    I haven't looked at Dancer 2, but Dancer 1 uses cookie-based sessions, so I feel comfortable assuming that Dancer 2 sessions are also cookie-based.

    While your suggestion of using more specific cookie paths is a good one, the OP should be aware that this would provide per-backend-server (or, more precisely, per-document-subtree) sessions, not per-tab sessions. So if, for example, you had two tabs open to bigserver, then those two tabs would still share a single session, even though it would be a separate session than the one in a third tab open to littleserver.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11102260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-18 08:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found