Apache/mod_rewrite for User Tracking

From: Date: Mon, 12 Feb 2001 10:46:39 +0000
Subject: Apache/mod_rewrite for User Tracking
Groups: php.general 
Request: Send a blank email to php-general+get-39199@lists.php.net to get a copy of this message
I'm not sure how off-topic this may be, but I'll carry on anyway... I wan't to create a user tracking system on the web site, that I can use in PHP. I've had a look at mod_rewrite, and would like to implemet something like the following: I have a few scripts, say 'home', 'search', 'help', etc. and all are force mapped onto PHP 4. If someone calls this scripts (without entering the site through the front door), then they are sent back, set a user tracking value, and sent back to the page. Before now, I have cookies and IP address for user tracking. If someone could accept a cookie (I used a self-referring script to check) then they are given a cookie, and they can be tracked. They can also be tracked over many visits with a cookie. If they don't then I make a note of their IP address, and their address is used. With IP addresses, you can't record return visits, so it just tracks one visit. With some ISP's they seam to use variying IP addresses, so then each page checked for a valid user, they didn't find one, and forwarded then back to 'index' to set a user session, and come back. But they seamed (to the server/PHP) to have different IP's over these steps, and the visitor was locked into a HTTP Redirect cycle (until the broswer stop with a fail). What I would like to do now is track the user with the URL. When someone calls the site, (ether through the front door, or sent back to get an ID), they are given an ID like so: 'KjsiHdbEyu8G645Dus96Sy54GD'. They are then sent to say, http://localhost/KjsiHdbEyu8G645Dus96Sy54GD/home. Using mod_rewrite, I can then get the tracking var (KjsiHdbEyu8G645Dus96Sy54GD), and rewrite the URL to http://localhost/home, and call the script. I know this is possible. Something like /^\/([a-zA-Z0-9]{80})\/(.*)/$1?$2/ could work for the rewrite rule, but rather than use $HTTP_SERVER_VARS["QUERY_STRING"] to get the var, as I use a GET vars for some functions, could I get a var which is sent to Apache, and then PHP accesses the var from there, and the rest is as normal? That's what I would prefer to do, but I'm not sure if it's possible (and explained it well enough). If I had to do something like /^\/([a-zA-Z0-9]{80})\/(.*)/$1?$2/ I would just have to develop to that instead. Failing that, any suggestions? Thanks in advance.. Jonathan Wright.. Webmaster http://www.kjtoombs.co.uk/ (http://www.kjtoombs.co.uk/home)

« previous php.general (#39199) next »