Forum Moderators: coopster
I am doing this to stop multiple logins under the same username. I have this:
session_start();
@mysql_query("UPDATE accounts SET sessid='md5(session_id())' WHERE member='$member'");
sessid is where I want to save the session_id. Any help much appreciated.
mysql_query("UPDATE `accounts` SET `sessid`='".md5(session_id())."' WHERE member='$member'");
Also, don't forget to escape
$member with mysql_real_escape_string [php.net]() if you haven't already done so.
Now i'm trying to get the session id from the users cookie. The cookie is named PHPSESSID
$result = mysql_query("SELECT COUNT(*) FROM accounts WHERE member='$member' AND sessid='".mysql_real_escape_string(md5(session_id()))."'");
$login_status = mysql_result($result,0,0);
}
if (0 == $login_status) {
//Testing below
echo "logout";
echo md5(session_id());
echo $member;
}
I can echo md5(session_id()) and $member fine.
I have found the session ids don't match up. When I login and set a session id for the user, and then update the db, it is differently set in the db. But both are 32 chars.
This is my code that sets the cookie and inserts it into table.
session_start();
$session = md5(session_id());
setCookie("session", $session);
@mysql_query("UPDATE $c->mysql_tb_id SET sessid='$session', WHERE member='$member'");