Dancer...Cookie(3pm)
π NAME π
ok so bestie, gather round: this is Dancer2::Session::Cookie β it's the thing that gives Dancer 2 its session storage, and it keeps all that session state inside secure cookies. yes, cookies. in the browser. but secure ones, we're not feral. πͺβ¨
π VERSION π
version 0.009 β that's the one, no cap.
β¨ SYNOPSIS β¨
drop this into your Dancer 2 config.yml and you're cooking:
# In Dancer 2 config.yml file
session: Cookie
engines:
session:
Cookie:
secret_key: your secret passphrase
default_duration: 604800
with_request_address: 0
like. that's it. that's the whole setup. π
πΈ DESCRIPTION πΈ
okay so here's the tea β: this module is a session factory</> for Dancer 2, and what it does is store your session state inside a browser cookie. wild, I know, but hear me out, because the features are lowkey stacked:
- Data serialization and compression using
Serealβ¨ - Data encryption using AES with a unique derived key per cookie π
- An enforced expiration timestamp β and that's independent of the cookie expiration, important detail bestie
- Cookie integrity protected with a message authentication code (MAC) π‘οΈ
fr fr, go read Session::Storage::Secure for the implementation details and the important security caveats. not optional. iykyk. π«Ά
π ATTRIBUTES π
π secret_key (required)
this is what secures your cookies, periodt. the encryption keys and the message authentication keys get derived from it using one-way functions. and bestie, listen: changing it will invalidate all sessions. all of them. every last one. π
β³ default_duration
the number of seconds the session may be considered valid. so if cookie_duration isn't set as part of the session configuration, this gets used instead β it expires the session after a period of time no matter how long the browser session happens to be. it's unset by default, which means session expiration is not capped. no vibes check on time, apparently.
π with_request_address
if you set it to "true", the secret key gets the request address appended to it β as provided by <$request->address>. this can help defeat some replay attacks (like, say, if the channel isn't secure). but π« it will also cause session interruption for people on dynamic addresses. so. tradeoffs. pick your fighter.
π SEE ALSO π
other CPAN modules that do cookie session storage (possibly for other frameworks, we don't gatekeep):
Dancer::Session::Cookieβ the Dancer 1 equivalent to this module πCatalyst::Plugin::CookiedSessionβ encryption onlyHTTP::CryptoCookieβ encryption onlyMojolicious::Sessionsβ MAC onlyPlack::Middleware::Session::Cookieβ MAC onlyPlack::Middleware::Session::SerializedCookieβ really just a framework, and you provide the guts with callbacksDancer2::Core::Role::SessionFactoryβ documentation of the base package, plus some more attributes to configure the cookie
π« AUTHOR π«
David Golden <dagolden@cpan.org> π«Ά
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2018, 2016, 2014 by David Golden.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
ok that's the whole page bestie, you ate it π
and for the record β this was Dancer...Cookie(3pm) from the User Contributed Perl Documentation, built for perl v5.40.1, dated 2025-03-03. mwah. πβ¨π
π¦ where this page comes from
- debian trixie: libdancer2-session-cookie-perl 0.009-2 Β· Apache-2.0
- ubuntu resolute: libdancer2-session-cookie-perl 0.009-2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms