Hi All,

 I'm currently using mod_usertrack to maintain a session id for each
request, then am logging this with my own perl Log handler.  This is all in
and working fine (thanks to a couple members of this list - Jacob Davies and
Ian Kallen - thanks guys!).  Unfortunately, since the cookie is set on the
first request, it is impossible to determine if the client has cookies
enabled.  (And I don't want to lose the referrer, so getting the information
from the cookie header is not an option, either).  So, I'm effectively doing
both and comparing:

        my $unique_session = $r->dir_config("LogName") . "\t" .
$Logfields{'hostname'};
        $Logfields{'si-uid'} = $r->notes('cookie'); # default
        my $cookies = fetchCookies($r->header_in('Cookie'));  # internal sub that
parses cookies
        if ($cookies && ($cookies->{'sessionid'} eq $Logfields{'si-uid'})) {
                # if cookie and notes are equal,
              # we're past 1st request and cookie are enabled
                # remove from session, we're fine
                $log->info("Cookies are equal: " . $Logfields{'si-uid'});
                set_sessionid($unique_session, undef);
        } else {
                # ok, no cookie yet
                # if it's defined in session, then it's past 1st request
                # cookies are disabled, use first request id
                my $id;
                if ($id = get_sessionid($unique_session)) {
                        $log->info("Got sessionid " . $id);
                        $Logfields{'si-uid'} = $id;
                        # log no cookies
                        $Logfields{'no_cookies'}++;
                } else {
                        # first request, squirrel for next request
                        $log->info("Setting sessionid to " . $Logfields{'si-uid'});
                        set_sessionid($unique_session, $Logfields{'si-uid'});
                }
        }

  This all works fine. However, the get_sessionid and set_sessionid are
using a dbm file, which is locked and unlocked during each request.  (I
know, I know).  Obviously, this is a lot more load that is necessary.  I
tried using a simple global variable (defined before the handler), but this
was unreliable as it was set differently for each request.  No doubt due to
different processes handling each request.  Can anyone suggest a better way
of handling this globablly accessed data?  Thanks.

Jim Sproull
[EMAIL PROTECTED]

Reply via email to