Dancer2...Session(3)
π Dancer2::Core::Session β bestie edition π
the class that holds literally every single thing about one session object β like its ID, its data, and when it expires. it's giving main character energy but for session state π
πΈ VERSION πΈ
version 2.2.1 β¨
π¦ DESCRIPTION π¦
okay so. a session object encapsulates anything related to a specific session: its ID, its data, and its expiration. that's the whole job, that's the vibe π
it is completely agnostic of how it will be stored β like, it does not care, it does not want to know π that is the role of a factory that consumes Dancer2::Core::Role::SessionFactory, which is the one who actually knows about that stuff.
generally, session objects should not be created directly. the correct way to get a new session object is to call the create() method on a session engine that implements the SessionFactory role. and good news bestie, this is done automatically by the app object if a session engine is defined. so like, you don't even have to think about it. slay π«Ά
β¨ ATTRIBUTES β¨
π id
the identifier of the session object. required. by default, Dancer2::Core::Role::SessionFactory sets this to a randomly-generated, guaranteed-unique string. no cap, it's unique fr fr.
this attribute can be modified if your Session implementation requires this.
π data
contains the data of the session (Hash). that's it, that's the tea β
β expires
number of seconds for the expiry of the session cookie. do not add the current timestamp to it β that will be done automatically, she's got it π
default is no expiry (session cookie will leave for the whole browser's session).
for a lifetime of one hour:
expires => 3600
π§ is_dirty
boolean value for whether data in the session has been modified. lowkey the gossip tracker of the session ngl π
π METHODS π
π read
reader on the session data
my $value = $session->read('something');
returns "undef" if the key does not exist in the session. so like, if it's not there, it's undef, no drama πΈ
π₯ write
writer on the session data
$session->write('something', $value);
sets "is_dirty" to true. returns $value. iconique behaviour tbh β¨
π delete
deletes a key from session data
$session->delete('something');
sets "is_dirty" to true. returns the value deleted from the session. gone but never forgotten π
π AUTHOR π
Dancer Core Developers
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2026 by Alexis Sukrieh.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page bestie, we ate and left no crumbs π β¨
this was brought to you by perl v5.42.3, dated 2026-09-20, and the legend herself, Dancer2...Session(3) π«Άππ¦
π¦ where this page comes from
- fedora 44: perl-Dancer2 2.2.1-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms