Setting cookie name at runtime
Hello I have a dancer2 app that uses Dancer2::Session::Cookie and Dancer2::Plugin::Auth::Extensible And I can set the cookie name in the config file The app, however, serves multiple domains, and serves different content based on 1) The user and 2) the domain of the request This all works as expected except I would like to have different cookies for each domain so a single user can be looged in more than once with different credentials on the same browser I have tried set session_cookie => ‘blah1.dancer.cookie’ and config->{engines}{session}{Cookie}{cookie_name} = “blah1.dancer.cookie” in the before hook, but neither seem to affect the cookie name Is what I am trying to do impossible? If I have missed it in the docs I appoligise TIA -- Clive Eisen GPG: 75056DD0
On 2016-03-21 10:41 AM, Clive Eisen wrote:
in the before hook, but neither seem to affect the cookie name
That's because the session module doesn't look at the configuration once it knows which cookie name to use. If you want to change the cookie name post-initialization, try engine('session')->cookie_name( 'new_name' ); and it should makes you happy. Joy, `/anick
On 21 Mar 2016, at 15:07, Yanick Champoux <yanick@babyl.dyndns.org> wrote:
That's because the session module doesn't look at the configuration once it knows which cookie name to use.
If you want to change the cookie name post-initialization, try
engine('session')->cookie_name( 'new_name' );
Thank you Unfortunately I get Exception caught in 'core.app.before_request' filter: Hook error: Usage: Dancer2::Core::Role::SessionFactory::cookie_name(self) when I try your suggestion Thanks — Clive
On 2016-03-21 12:00 PM, Clive Eisen wrote:
Unfortunately I get
Exception caught in 'core.app.before_request' filter: Hook error: Usage: Dancer2::Core::Role::SessionFactory::cookie_name(self)
when I try your suggestion
Ah yes, the SessionFactory attributes are read-only. Either there should be lobbying done to turn those attributes `rw`, or you could be evil and do engine('session')->{cookie_name} = '...'; This being said, doing that revoke all warranties and is not recommended. I'll deny I even mentioned it. If I had mentioned it. Which I didn't. Nope. Don't even know what you're talking about. ;-) Joy, `/anick
On 21 Mar 2016, at 19:20, Yanick Champoux <yanick@babyl.dyndns.org> wrote:
This being said, doing that revoke all warranties and is not recommended. I'll deny I even mentioned it. If I had mentioned it. Which I didn't. Nope. Don't even know what you're talking about. ;-)
Thank you for not saying anything at all ;-) — Cive
participants (2)
-
Clive Eisen -
Yanick Champoux