++ed by:
BEROV

1 PAUSE user
1 non-PAUSE user.

Konstantin S. Uvarin

NAME

MVC::Neaf::X::Session::File - File-based sessions for Not Even A Framework.

DESCRIPTION

This module implements session storage, as described in MVC::Neaf::X::Session.

It will store session data inside a single directory. The file format is JSON but MAY change in the future.

Uses flock() to avoid collisions.

If session_ttl was specified, old session files will be deleted.

NOTE The file-locking MAY be prone to race conditions. If you want real secure expiration, please specify expiration INSIDE the session, or use a database.

SYNOPSIS

    use strict;
    use warnings;
    use MVC::Neaf;
    use MVC::Neaf::X::Session::File;

    MVC::Neaf->set_session_engine(
        engine => MVC::Neaf::X::Session::File->new( dir => $mydir )
    );
    # ... define your application here

METHODS

new( %options )

Constructor. %options may include:

  • session_ttl - how long to store session data.

  • dir (required) - where to store files.

save_session( $id, \%data )

Save session data to a file.

load_session( $id )

Load session data from file. Will DELETE session if session_ttl was specified and exceeded.

delete_session( $id )

Remove a session, if such session is stored at all.

atomic_read( $id )

Internal mechanism beyond load_file.

atomic_write( $id, $content )

Internal mechanism beyond save_session.

get_file_name( $id )

Convert id into filename.

encode_content( $data )

decode_content( $raw )

Currently JSON is used.