Gossamer Forum
Home : Products : DBMan : Customization :

LoisC cookie mod problem

Quote Reply
LoisC cookie mod problem
Hi,

I've installed LoisC's cookie mod for logging in on my site. I've got several 'html.pl' files working with one db.cgi and auth.pl file. So I figured once a cookie would be written, it would work on all databases, for example, that I would be logged in when I use

http://www.allesoversterrenkunde.nl/cgi-bin/scripts/db.cgi?db=nieuws

or

http://www.allesoversterrenkunde.nl/cgi-bin/scripts/db.cgi?db=boeken

no matter where I once logged in.

However, this is not the case. To be honest: it's rather vague what exactly goes wrong... At some databases I stay logged in, at others I have to manually log in although I see no differences...

I'll check my cfg files again, maybe it has something to do with something in there....

Anyway, if anybody knows what I'm talking about it or had the same, I'd appreciate all answers.

I've got the following in the cookie mod:

auth.pl:

my $q = new CGI;
my %cookval;
$cookval{'username'} = "$userid";
$cookval{'password'} = crypt($in{'pw'}, $pw);
my $cookie_out = $q->cookie(-name=>"allesoversterrenkundelogin",
-value=> \%cookval,
-domain => "www.allesoversterrenkunde.nl",
-expires=>'+6M', # cookie expires after 6 months - adjust as you please
-path=>'/',

db.cgi:

my $q = new CGI;
my %cookval = $q->cookie("allesoversterrenkundelogin");
my $userid = $cookval{'username'};
my $password = $cookval{'password'};

if ($userid) { # if there's a cookie, create a session ID using the username from the cookie
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
$db_uid = "$userid." . time() . (int(rand(100000)) + 1);# Build User Id
open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$db_uid. Reason: $!\n");
print AUTH "$db_uid: $ENV{'REMOTE_HOST'}\n";

close AUTH;

Lex
Quote Reply
Re: [Lex] LoisC cookie mod problem In reply to
I'm not sure which cookie mod you are using? I've never written one myself :)

Looking at my notes for:

C O O K I E M O D
Written by: Eli Finkelman

I found this thread with the problem with two databases and a solution which worked for one user.

Re: MOD: Session Cookie
anr 5-Jul-00

I figured it out.

When $Cookie_Path = ''; is left blank it uses the path that sets it.
So I changed it to $Cookie_Path = '/cgi-bin'; and now it seems to be working. (Still in both Netscape and IE.) Log into one, cookie is set, head over to the other and the door is wide open

If that doesn't help, I would suggest searching for "cookie mod" and viewing the related threads to see what has worked for others.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/