You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joshua Chamas <jo...@chamas.com> on 2001/09/21 09:16:31 UTC
Re: Apache::ASP - using Apache::Session
Jindo Soul wrote:
>
> Hi!
>
> I recently made a decision to adopt Apache::ASP as the template tool for my site. The only thing I'd like to find out is whether or not Apache::ASP works with Apache::Session. I read from an online article http://perl.apache.org/features/tmpl-cmp.html that Apache::ASP can be hookied up to Apache::Session. However, I just could not find the instruction on how this can and should be done. Am I mistaken or have I missed something in the online docs?
>
Note the Apache::ASP mailing list is now at: asp@perl.apache.org
Subscribe by sending an email to asp-subscribe@perl.apache.org
Integration of Apache::Session is similar to other environments,
except where you put the code. In Apache::ASP, you can put it
in global.asa Script_OnStart to get run every time, then you
can init the session to look like the ASP $Session.
The only differences are you don't get the ASP API around $Session,
like session management with garbage collection/timeouts, events,
or other API calls like Lock(), Abandon(), SessionID().
Also, without using ASP session, you won't get to use
SessionQueryParse cookieless sessions either.
Here is some untested code that you could start with
for using Apache::Session with MySQL:
# in httpd.conf, turn off $Application, $Session
PerlSetVar NoState 1
# in global.asa
use Apache::Session::MySQL;
sub Script_OnStart {
# ... init mysql dbh before
my $id = $Request->Cookies("SESSION_ID");
tie %hash, 'Apache::Session::MySQL', $id, { Handle => $dbh, LockHandle => $dbh };
if($id ne $hash{_session_id}) {
$Response->Cookies("SESSION_ID", $hash{_session_id});
}
$Session = \%hash;
$Server->RegisterCleanup(sub { untie (%$Session) }); }
}
--Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051