DESCRIPTION

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

SINOPSYS

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

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

1;

METHODS

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.

encode

decode

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.

LICENSE AND COPYRIGHT

This module is part of MVC::Neaf suite.

Copyright 2016-2023 Konstantin S. Uvarin khedin@cpan.org.

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 http://dev.perl.org/licenses/ for more information.