perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jay Jacobs <>
Subject RE: Apache::Session
Date Thu, 01 Jun 2000 20:19:06 GMT
Mod_Rewrite does the same thing in a few less lines:

RewriteEngine On
RewriteCond /your/document_root/%{REQUEST_FILENAME} !-f
RewriteRule ^/S([^/]+)/(.*)    /$2 [E=SESSION_ID:$1]

the RewriteCond statement just makes sure you don't (for some strange
reason) have a file/directory that is of the same name as the request, and
it's completely removable 

This also doesn't change the $r->uri value, but I find that kind of a

Jay Jacobs
LachNet Inc.

On Thu, 1 Jun 2000, Michael Nachbaur wrote:

> Well, from what I'm reading, it looks like you don't want it to create sessions for all
images, CSS, et al on the first page load, right?  Instead of deleting sessions that aren't
used, you could try just not serving sessions to documents that don't need 'em.
> Like in my setup, I've put in a PerlTransHandler pointing to a custom perl module I've
> PerlTransHandler  Apache::URISession
> Then, in Apache::URISession, I've done the following:
> package Apache::URISession;
>  use strict;
>  use Apache::Constants qw(:common);
>  sub handler {
>     my $r = shift;
>     my $uri = $r->uri;
>     my ($session) = $uri =~ m|/S([0-9a-f]{32})|;
>     $uri =~ s|/S[0-9a-f]{32}||;
>     my $filename = $r->document_root . $uri;
>     $ENV{'SESSION_ID'} = $session if ( $session );
>     print STDERR "SESSION: " . $session, "\n";
>     print STDERR "URI    : " . $uri, "\n";
>     $r->uri($uri);
>     $r->filename( $filename );
>     return OK;
>  }
>  1;
>  __END__
> There might be another module that does this, but I wanted to embed the session key in
the URL.  So, in this example, it'll redirect the user to an address like this one:
> It'll rip the session out, put it in ENV{SESSION_ID}, and continue processing.  I'm not
sure if I should be returning an OK there or not (I'm new to using handlers), but it does
the job.
> Also, keep in mind, I'm using the new Apache::Session which creates 32-character keys,
which is why I'm doing the pattern match check like {32}.
> -man
> -----Original Message-----
> From: Niral Trivedi []
> Sent: Thursday, June 01, 2000 12:57 PM
> To:
> Subject: Apache::Session
> All,
> I need to clear myself on a small issue regarding Apache::Session.
> As per my understanding, Apache::Session will store session information
> in a backing store-either a flat file or in some database. And
> everytime, request comes in, it will check for sessionID in backing
> store and retrieve all information for that session. If request is new
> than it will create new sessionID and also create an entry in backing
> store..
> Now, only way to remove this information from backing store is to do
> 'tied(%session_hash)->delete', Am I right? I mean is there any way we
> can remove these entries by setting 'time_out_interval' or something
> like that?? 
> Because if we do 'tied(%session_hash)->delete' then it will create new
> session for every request... So, I was thinking of not doing
> 'tied->delete' but write a small cron script which runs at specified
> interval and removes entry from backing store which are older than some
> time...
> Because concept of 'time_out_interval' does exist in Apache JServ and
> other application servers..
> Any ideas, suggestions or pointers on this???
> Thanks again..
> Niral
> --

View raw message