Gossamer Forum
Home : Products : DBMan : Customization :

auto login

Quote Reply
auto login
I've installed the cookie-script from http://www.worldwidemart.com/scripts/ and make some changes in the db.cgi and auth.pl.

db.cgi:

Just under the 'elsif' statement for 'logout':
elsif ($in{'lib'}) {

if (&GetCookies('username','password')) {
$user = $Cookies{'username'};
$pass= $Cookies{'password'};
$new_url = "$db_script_url?db=$db_setup&userid=$user&pw=$pass&login=1";}

else { $new_url = "$db_script_url";}

$loc_cookie ? (print "Location: $new_url\n\n") : (print "Location: $new_url\n\n");
}


New sub:
sub get_date_cookie {
# --------------------------------------------------------
# Returns the date in the format "Wdy, DD-Mon-YYYY HH:MM:SS GMT ".
# Wil only be used with &SetCookies.
# Define your $cookie_exp in the .cfg file for the number of days, the cookie must be set.

my $cookie_time = &get_time;
my ($time1) = @_[0];
($time1) or ($time1 = time());

$time1 = $time1 + (86400 * $cookie_exp);

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mrt Apr Mei Jun Jul Aug Sep Okt Nov Dec!;
my (@Weekdays) = (Sun,Mon,Tue,Wed,Thu,Fri,Sat);
$dag = $Weekdays[$dweek];
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$dag, $day-$months[$mon]-$year $cookie_time GMT";
}


In your .cfg file:
# Number of days for the cookie to expire.
$cookie_exp = 30;


In the 'auth.pl', sub 'auth_check_password', just under
if (($in{'userid'} eq $data[0]) && (crypt($in{'pw'}, $pw) eq $pw)) {
$cook_d = &get_date_cookie;
&SetCookies('username', $in{'userid'},'password', $in{'pw'});
&SetCookieExpDate('$cook_d');


You can define the variable '$loc_cookie =1;' in your .cfg, but that isn't needed.

Then I've set the url to my dbman in my frameset to htp://path/to/dbman/db.cgi?db=default&uid=default&lib=1&login=1
When a user has made an account before, he can be welcomed with his own 'userid' and do not have to logon, he already is Smile

If anyone notice some security danger for authentication or something, please tell...


----------
Mart.
Quote Reply
Re: auto login In reply to
There's a dusicussion goin on in the Discussion forum about cookies and their potential risks, alternatives, etc.

You may want to check that out...

Regards,

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: auto login In reply to
Hi Astro Boy,

Do you notice any security danger by this mod?? It's working like charme...Smile

----------
Mart.