Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Keeping track of a session id (mod_rewrite?)

by davidrw (Prior)
on Jun 18, 2005 at 15:20 UTC ( #467995=note: print w/replies, xml ) Need Help??


in reply to Keeping track of a session id (mod_rewrite?)

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://467995]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-09-30 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?