The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CGI::Session::YAML - A session-handling module that uses YAML for storage.

SYNOPSIS

    use CGI::Session::YAML;
    my $query = CGI::Session::YAML->new('/var/tmp/mysessiondir');

    $query->param(-name => 'foo', -value => 'bar');

    $query->commit();

DESCRIPTION

This module is a CGI module proxy that overrides the basic param handling methods in the CGI module, and causes them to be saved in a YAML storage file for reloading afterwards.

The session id is stored in the CGI parameter .id, with a new one being created if not supplied. The ID is a 128-bit UUID created via Data::UUID.

The session is not saved until the commit() method is called. Conversely the constructor will load an existing session file if there is one to load, based on the session ID and the session directory. As the session directory does default to the /tmp directory, supplying a different one is recommended.

new

This is the class constructor. It takes an optional parameter, which is the session directory. It is highly recommended to provide one with the proper permissions for your setup, as opposed to using the default of /tmp.

The constructor will look in the session directory, and check for an .id CGI parameter, and load $sessiondir/$id as its initial session, if it exists. If .id does not exist, it will create a new session.

param

This is a proxy to CGI::param, but it intercepts CGI parameters being set so that it may update storage.

delete

This is a proxy to CGI::delete, but it intercepts CGI parameters being deleted so that it may update storage.

delete_all

This is a proxy to CGI::delete_all, but it intercepts CGI parameters being deleted so that it may update storage.

commit

This method causes the session file to be updated with the latest cached CGI parameters.

AUTHOR

Michael P. Soulier <msoulier@digitaltorque.ca>

COPYRIGHT

Copyright 2007 Michael P. Soulier. All rights reserved.

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

SEE ALSO

CGI, Data::UUID