NAME

Mojolicious::Sessions::Store::Backend::File - File-based session storage backend

VERSION

version 0.01

SYNOPSIS

use Mojolicious::Sessions::Store::Backend::File;

my $backend = Mojolicious::Sessions::Store::Backend::File->new(
    store_dir => '/path/to/sessions',
);

my $data = $backend->load('abc123');
$backend->save('abc123', { user_id => 42 });
$backend->delete('abc123');

DESCRIPTION

Stores session data as JSON files on the filesystem. Each session is a single file named $session_id.json in the store_dir directory.

Writes are atomic (write to temp file, then rename) to prevent corruption on crash.

NAME

Mojolicious::Sessions::Store::Backend::File - File-based session storage backend

ATTRIBUTES

store_dir

my $dir = $backend->store_dir;
$backend = $backend->store_dir('/path/to/sessions');

Directory where session files are stored. Required. Created automatically if it does not exist.

METHODS

load

my $data = $backend->load($session_id);

Reads and decodes the JSON file. Returns a hashref or undef.

save

$backend->save($session_id, $data);

Writes the session data as JSON to an atomic temporary file, then renames it to the final filename.

delete

$backend->delete($session_id);

Removes the session file if it exists.

SEE ALSO

Mojolicious::Sessions::Store, Mojolicious::Sessions::Store::Backend

AUTHOR

Daniel Brosseau <dab@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Daniel Brosseau.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.