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


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