[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cgiapp] logging in with CGI::Session and CGI::Application


    :
    :I've not even looked at it before.. is it much like CGI::Session??

Apache::Session is indeed one of the best session managing libraries
available.
In fact, the very first release of CGI::Session was simply an OO wrapper
around
Apache::Session, allowing people to use a more user friendly, and the
most
familiar object oriented syntax instead of tied hash interface. So
CGI::Session 1.x
was an extended version of Apache::Session. CGI::Session 2.x was
Apache::Session
independant, with lots of more built features, and supported the same
operations as Apache::Session did,
and CGI::Session 3.x added even more stuff onto it, including expiring
certain session parameters,
and configuring the session drivers on the fly.

In other words, CGI::Session was created by someone who had been using
Apache::Session
for a long time in the production environment, and wanted something more
than Apache::Session offers.

Here are samples of code to compare the two syntaxes:

Object Initialization:

	# In CGI::Session
	$s = new CGI::Session(undef, $cgi, {Directory=>"/tmp"});

	# in Apache::Session:
	my $sid = $cgi->cookie('SID') || $cgi->param('SID') || undef;
	tie %s, "Apache::Session::File", $sid, {Directory=>"/tmp",
LockDirectory=>"/tmp"};

Storing data in the session:

	# In CGI::Session:
	$s->param(key=>value, key2=>value2, ...);

	# In Apache::Session:
	$s{key} = $value;
	$s{key2} = $value2;

Reading data:

	# In CGI::Session
	print $s->param('key1');

	# in Apache::Session
	print $s{key1};

Save CGI parameters in the session:

	# In CGI::Session:
	$s->save_param($cgi);

	# In Apache::Session:
	for ( $cgi->param() ) {
		my @params = $cgi->param($_);
		if ( @params > 1 ) {
			$s{$_} = suppressed;
		} else {
			$s{$_} = @params;
		}
	}

Sherzod

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.