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::Persist -- Web persistency made usable.

SYNOPSIS

  my $cgi = CGI::Persist->new(sessionTime => 60);

DESCRIPTION

The base class for CGI::Persist::DBI and CGI::Persist::File, is NOT capable of storing anything for itself (not even using cookies - since they are evil)

This all gives you full access to the CGI interface.

FUNCTIONS

new
  ( sessionTime => 900, 
    logFile => " ", 
    errorLogFile => " ", 
    writeOnce => [ ], 
    filter => [ ], 
    mask => [ ], 
    run => sub { return undef } );

Creates a new instance of the CGI::Persist object. Running this once should be enough.

newSession

Creates a new session. It will not overwrite the current session object in the DB.

newFromIdle

Is set to 1 if the previous session has dissapeared and a new session had to be created.

firstRun

Is set to 1 if this is the first hit on a session.

data (key)
data (key => value)

If the only argument is a key, the matching piece of data is found to that, and returned. If a value is also submitted this will be stored.

In void context an anonymous hash is returned with all key => value pairs inside.

currentParam

Holds the 'current' parameters (eg: the parameters that where found before the session was restored.);

gotSubmit

Feature for checking (image)buttons have been pressed

cleanUp

Will round up all the sessions older then sessionTime and ask to delete them.

log

writes to the logFile

errorLog

writes to the errorLogFile

paramFetchHash

returns an anonymous hash of all parameters in memory.

href

returns a CGI::href, but with an ID nicely tucked in there.

stateUrl

return the current URL + '?ID=$ID'

stateField

returns a hidden-field tag for your form holding ID and its value

WRITING YOUR OWN CHILD

isnt to hard. Just make sure it has the following routines:

  openDB
  closeDB
  store
  get
  findOldSessions
  clean($id)

And make sure that these routines do what their names promisse.

KNOWN BUGS

None so far.

CHANGELOG

20051209 : Discoverd that value arrays are not stored correctly, Fixed. 20051219 : Prevented lots of warnings due to more defensive if/unless constructions : Added test for DBI

THANKS TO

Robert Bakker <robert@2organize.com> Arno F. Roelofs <arnofr@2organize.com>

AUTHOR

Hartog C. de Mik <hartog@2organize.com>