I could be misunderstanding, but i'm not sure it's possible since mod_rewrite only acts on "inbound" urls... So client logins into your site, thus establishing a session on the server. Now, the client asks for foo.html -- how could mod_rewrite know how to match this new client request (which could be from any client) with a session id on the server side? (no cookie, can't rely on remote IP, no info yet in query string)
I don't know if there's anything in perl/mod_perl/cgi-world that does the same transparent query string appending of session id that php can do (i hope so and that someone will mention it), but here's another alternative: You could write a filter for your outbound content that finds relative urls and appends the session id to the query string. I've used this method to encrypt query strings, so query strings don't look like ?year=3&type=search&btn=find but instead like s=<somebignumber>. To set this up need the following:
need something like this in http.conf:
PerlModule Apache::Filter \
OurStuff::SessionFilter
<Directory "/www_doc_root/">
PerlHandler OurStuff::SessionFilter
SetHandler perl-script
</Directory>
And the OurStuff::SessionFilter looks like:
package OurStuff::SessionFilter;
use Apache::Constants();
sub handler {
my $r = shift;
$r = $r->filter_register();
my($fh, $status) = $r->filter_input();
return $status unless $status == Apache::Constants::OK();
my $session_id = OurStuff::Session->getCurrent()->id;
# now the hard part: process the $fh filehandle and
# find relative urls, and add &session=$session_id to
# the query string.
# keep in mind that urls can be embedded in javascript,
# such as location.href='...' or window.open(...)
return OK;
}
1;
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|