PDA

View Full Version : Cant extract info from cookie


kgp43
09-25-2004, 10:43 AM
Hey,

My forums are located in a directory and not a subdomain: http://www.domain/forums
I need to use the username and password from the cookie, in other areas of my website, so I changed the name of the cookie to: .domain.com

Searched the forums and found some code (used for extracting data from the cookie). I modified it a little, so it fit my needs:

//Select the forum database
mysql_select_db ("perfume_forums");

$userid = intval($_COOKIE[bbuserid]);
$password = addslashes($_COOKIE[bbpassword]);
$result = mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'LicenseNo')) = '$password'");
$user = mysql_fetch_array($result);
if ($user[userid]) {
//echo "<input name='user_name' type='hidden' value='$user[userid]'>";
echo "User: ".$user[username];
} else {
echo "<input name='user_name' type='text' class='rating-form' maxlength='20'>";
}



- why doent this work?

kgp43
09-26-2004, 01:53 PM
anyone? Shouldnt it work?

kgp43
09-27-2004, 06:51 PM
Can anyone see a error in this:

$userid = intval($_COOKIE[bbuserid]);
$password = addslashes($_COOKIE[bbpassword]);
$result = mysql_query("SELECT username, userid FROM user WHERE userid=$userid AND MD5(CONCAT(password, 'LicenseNo')) = '$password'");
$user = mysql_fetch_array($result);

if ($user[usernmae]) {
echo "bla bla";
}else{
echo "no bla bla";
}

- If I replace $user[username] with $userid or $password, then it echo "bla bla"

Xenon
09-28-2004, 07:00 PM
you forgot the salting

look at login.php around line 139 to see how vb's passwords are build

kgp43
10-08-2004, 08:01 AM
it is working now :)