Sponsored Content
Top Forums Web Development How do I verify my web visitor is still online Post 302284663 by otheus on Friday 6th of February 2009 04:23:35 AM
Old 02-06-2009
One thing you can do with Apache is to create a seperate logfile with just the Cookie (and access time). You can then send this log through a program which monitors the last time a cookie was used, and if it has gone past the time you want, you remove it from the database. So a configuration in apache would look like:
Code:
CustomLog "|/usr/local/bin/user_tracker" cookies
LogFormat "%v\t%{s}t\t%200{Foobar}C" cookies

Where Foobar is the name of your cookie that identifies the user session.
The logs are sent to a script (/usr/local/bin/user_tracker) like this one:
Code:
#!/usr/bin/perl -n
chomp;
($vhost,$time,$cookie)=split("\t");

# Remember this cookie
$Cookies{$vhost . ":" .  $cookie}=$time;

# Every 5 minutes, scan through cookies and remove obsolete database entries
if ($time >= $next_check)  {
    while ( ($cookie,$cookie_time) = each(%Cookies) ) {
       if ($cookie_time >= $expire_time) {
         delete $Cookie{$cookie}; 
         push @to_delete, $cookie;
       }
    }
    foreach (@to_delete) { 
         ($vhost, $cookie_name, $cookie_value) = m/^(.*?):(.*?)=(.*)/;
         # Insert code here to delete $cookie_value from database
       }
    }
    $next_check = $time + 5*60;    # Check for expired cookies every 5 minutes
    $expire_time = $time + 20*60;   # Expire cookies every 20 minutes
}

 

We Also Found This Discussion For You

1. Post Here to Contact Site Administrators and Moderators

Suggestion: visitor graphs

Perhaps we could think of visitor graphs that would give a sense of both the popularity of the forum and - more importantly - the popularity of Linux and the Open Source operating systems movement. Something similar to what sourceforge has done for their projects: SourceForge.net: Project... (2 Replies)
Discussion started by: figaro
2 Replies
HTTP::Cookies::Microsoft(3)				User Contributed Perl Documentation			       HTTP::Cookies::Microsoft(3)

NAME
HTTP::Cookies::Microsoft - access to Microsoft cookies files SYNOPSIS
use LWP; use HTTP::Cookies::Microsoft; use Win32::TieRegistry(Delimiter => "/"); my $cookies_dir = $Registry-> {"CUser/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Cookies"}; $cookie_jar = HTTP::Cookies::Microsoft->new( file => "$cookies_dir\index.dat", 'delayload' => 1, ); my $browser = LWP::UserAgent->new; $browser->cookie_jar( $cookie_jar ); DESCRIPTION
This is a subclass of "HTTP::Cookies" which loads Microsoft Internet Explorer 5.x and 6.x for Windows (MSIE) cookie files. See the documentation for HTTP::Cookies. METHODS
The following methods are provided: $cookie_jar = HTTP::Cookies::Microsoft->new; The constructor takes hash style parameters. In addition to the regular HTTP::Cookies parameters, HTTP::Cookies::Microsoft recognizes the following: delayload: delay loading of cookie data until a request is actually made. This results in faster runtime unless you use most of the cookies since only the domain's cookie data is loaded on demand. CAVEATS
Please note that the code DOESN'T support saving to the MSIE cookie file format. AUTHOR
Johnny Lee <typo_pl@hotmail.com> COPYRIGHT
Copyright 2002 Johnny Lee This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2012-02-15 HTTP::Cookies::Microsoft(3)
All times are GMT -4. The time now is 06:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy