MVC::Neaf::X::Session::Base - session engine base class & tooling for Not Even A Framework.


    package My::Session::Engine;
    use parent qw(MVC::Neaf::X::Session::Base);

    sub store { ... };
    sub fetch { ... };



new( %options )

%options may include:

  • session_ttl - how long until session expires (not given = don't expire).

  • session_renewal_ttl - how long until session is forcibly re-saved and updated. Defaults to session_ttl * some_fraction. 0 means don't do this at all.

save_session( $id, $hash )

Save session data. Returns hash with keys id and expire. Returned id MAY differ from the given one, and must be honored in such case.

load_session( $id )

Load session by id. A hash containing session data, id, and expiration time is returned.

Session is re-saved if time has come to update it.

get_expire ( $time || time )

Caclulate expiration time, if applicable.

need_renewal( $time )

Tell if session expiring by $time needs to be renewed.



fetch ($id)

Stub, to be redefined by real storage access method. Return is expected as { data => stringified_session }.

store( $id, $stringified_data, $data_as_is)

Stub, to be redefined by real storage access method.

Must return false value or a hash with following fields (all optional):

  • id - indicates that id has changed and/or client session needs update;

  • expire - indicates that expiration date has changed and/or needs update;

  • strfy - stringified session data;

  • override - hash with individual fields that would override decoded content.


This module is part of MVC::Neaf suite.

Copyright 2016-2019 Konstantin S. Uvarin

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.