[ic] User Sessions

interchange-users@icdevgroup.org interchange-users@icdevgroup.org
Thu Jun 20 07:17:02 2002


On Thu, Jun 20, 2002 at 10:13:35AM +0200, Stefan Hornburg (Racke) wrote:
> cfm@maine.com writes:
> 
> > On Tue, Jun 11, 2002 at 01:33:30PM -0500, Curt Hauge wrote:
> > > Jim Webster said:
> > > 
> > > > Is it possible to show "current users logged in" or at
> > > > least "users logged
> > > > within the last hour"?  If so, any help is appreciated... thx.
> > > 
> > > I have made a html page for clients like this, thanks to Dave Barr who
> > > posted the code. Kevin Walsh put another spin on it, search for his
> > > name in the archives:
> > > 
> > > <html>
> > > <head>
> > > </head>
> > > <body>
> > > 
> > > [calc]
> > >    my $sessions = q{[dump-session find=1]};
> > >    my @array = split(/\s+/, $sessions);
> > >    my $num = @array;
> > >    my $out = $num . " people are currently surfing my site" ;
> > >    return $out;
> > > [/calc]
> > > 
> > > </body>
> > > </html>
> > > 
> > > Good luck!
> > > 
> > 
> > Running find over the sessions?  That might not work well on 
> > busy site or where you don't expire sessions frequently.  You
> > might instead make some [tag] that just updates a smaller structure,
> > either a file, a directory or even db.
> 
> To get an accurate number of peoples online you have to know which
> sessions are expired. Only watching login/logout isn't enough so
> you have to walk through the sessions anyway. In this case it might be
> worth to store the sessions in SQL.

Here's one such structure; it's not so much intended to track
sessions as to maintain stock of limited items, decrementing
inventory where shoppers have items in carts but not yet checked
out.  Sessions last 30 min on this particular site.  This 
structure gets updated for each catalog page access.  We do
keep it in sql, but a maildir type thing providing timestamps
via stat might be enough for "who's on".

{
  'online' => 1,
  'localtime' => 'Thu Jun 20 06:03:21 2002',
  'time' => 1024571001,
  'skus' => {
    'HB36581' => '1'
  },
  'items' => {
    'ZMaPDVXj' => [],
    'C29dvI7o' => [
      {
        'code' => 'HB36581',
        'quantity' => 1
      }
    ]
  },
  'times' => {
    'ZMaPDVXj' => 1024571001,
    'C29dvI7o' => 1024570545
  },
  'offline' => 0
}


> 
> Ciao
>         Racke
> 
> -- 
> Prolific Interchange Consulting (Excellent German Quality !).
> Take a look at Materialboerse (http://www.materialboerse.de/), WITT 
> (http://www.witt-weiden.de/), Boxmover (http://shop.boxmover.ch/) or 
> Passionshop (http://www.passionshop.com/racke). Need a shop ? Contact us.
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
> 

-- 

Christopher F. Miller, Publisher                               cfm@maine.com
MaineStreet Communications, Inc           208 Portland Road, Gray, ME  04039
1.207.657.5078                                         http://www.maine.com/
Content/site management, online commerce, internet integration, Debian linux