in reply to usertracking

Hello khippy

This is a good effort. There are however a few things I would change.

I would suggest using my to add scope to your variables in your subroutines. You are currently declaring all your vars at the top of the script and then using them all in your subs. This makes them all essentially global (at least within the code you present).

I would also suggest adding most of the code in your "Main" section to a sub called isLoggedIn() or something. Put all of that code somewhere out of the way - maybe in a module if you can.

I also highly recommend reading merlyn's column on cookie management. The code snippet he presents is quite short and the commentary is illuminating.

I have recently written a module based on the idea in that column that makes it easy to drop in to different projects that authenticate using different methods.

Of course, I'm slightly reinventing the wheel, there already exists Apache::Session and CGI::MxScreen which do similar things and probably more. So mine probably will not make its way to CPAN, but I'll post it here.

Update: I would also suggest looking at Tricks with DBI especially the section on placeholders.

Simon Flack ($code or die)
$,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
=~y'_"' ';eval"die";print $_,lc substr$@,0,3;

Replies are listed 'Best First'.
Re: Re: usertracking
by khippy (Scribe) on Sep 22, 2001 at 23:27 UTC

    Thanks for looking at the code, Simon!
    Thanks also for the suggestions for code improvements.
    As this snippet is "currently being worked at" they are quite
    useful.
    One thing, I don't want to follow is the cookie thingy. I started
    this script especially to avoid the use of them because some people
    don't want to allow them, so why force them if there is a way out of
    it?
    I also know, that I am reinventing the wheel :) but on the other hand
    I wanted to create a secure login-procedure totally independent of
    other people's code - but maybe I should better look at the modules
    you suggested nevertheless.
    This has been a good way to study a usertracking, so far. I'd appreciate
    some security experienced people to say a word about the idea I am
    following.
    --

    there are no silly questions killerhippy