Mib1
10-25-2002, 07:47 AM
Below is what I have executing via an SSI. We have a membership site and what to load a cookie upon login that VB would then read so the member wouldn't have to enter their password again.
The member's details are already written to VB's database tables after they first become a member.
Can you tell me what else is needed to make this code load the cookie?
<?
// ############################### start login ###############################
$username = $PHP_AUTH_USER;
// if the username is in the database write VB cookie
$DB_site = mysql_connect("localhost", "us3939", "3434");
mysql_select_db("db3939");
if (isset($username)) {
// get userid for given username
if ($user=$DB_site->query_first("SELECT userid,username,password,cookieuser FROM user WHERE username='".addslashes(htmlspecialchars($username))."'")) {
exit;
}
$userid=$user[userid];
exit;
}
if ($user['cookieuser']==1) {
vbsetcookie("bbuserid",$user['userid']);
vbsetcookie("bbpassword",md5($user['password']));
}
$DB_site->query("DELETE FROM session WHERE sessionhash='".addslashes($session[dbsessionhash])."'");
$session['sessionhash']=md5(uniqid(microtime()));
$session['dbsessionhash']=$session['sessionhash'];
$DB_site->query("INSERT INTO session (sessionhash,userid,host,useragent,lastactivity,st yleid) VALUES ('".addslashes($session['sessionhash'])."','$userid','".addslashes($session['host'])."','".addslashes($session['useragent'])."','".time()."','$session[styleid]')");
vbsetcookie("sessionhash",$session['sessionhash'],0);
$username = $user['username'];
}
}
?>
The member's details are already written to VB's database tables after they first become a member.
Can you tell me what else is needed to make this code load the cookie?
<?
// ############################### start login ###############################
$username = $PHP_AUTH_USER;
// if the username is in the database write VB cookie
$DB_site = mysql_connect("localhost", "us3939", "3434");
mysql_select_db("db3939");
if (isset($username)) {
// get userid for given username
if ($user=$DB_site->query_first("SELECT userid,username,password,cookieuser FROM user WHERE username='".addslashes(htmlspecialchars($username))."'")) {
exit;
}
$userid=$user[userid];
exit;
}
if ($user['cookieuser']==1) {
vbsetcookie("bbuserid",$user['userid']);
vbsetcookie("bbpassword",md5($user['password']));
}
$DB_site->query("DELETE FROM session WHERE sessionhash='".addslashes($session[dbsessionhash])."'");
$session['sessionhash']=md5(uniqid(microtime()));
$session['dbsessionhash']=$session['sessionhash'];
$DB_site->query("INSERT INTO session (sessionhash,userid,host,useragent,lastactivity,st yleid) VALUES ('".addslashes($session['sessionhash'])."','$userid','".addslashes($session['host'])."','".addslashes($session['useragent'])."','".time()."','$session[styleid]')");
vbsetcookie("sessionhash",$session['sessionhash'],0);
$username = $user['username'];
}
}
?>