Login integration with multiple users from sql

Hi, I am trying as others to integrate the login system in my cms.
I have problems as well.

My auth script is like this

`code`
function authenticate()
{
if (isset($_POST["username"]) &&
isset($_POST["password"])) {

$_SESSION["username"] = $_POST["username"];
$_SESSION["password"] = md5($_POST["password"]);

$this->page = "";
$this->sub = "";
}

if (isset($_SESSION["username"]) &&
isset($_SESSION["password"])) {
$result = mysql_query("SELECT * FROM `users` WHERE `username` = '".mysql_real_escape_string($_SESSION["username"])."'");

if (mysql_num_rows($result) != 1) {
$this->logout();

$this->page = "authenticate";
$this->sub = "error";

return;
}

$row = mysql_fetch_assoc($result);

if ($_SESSION["password"] != $row["password"]) {
$this->logout();

$this->page = "authenticate";
$this->sub = "error";

return;
}

$this->user = $row;

} else {
$this->page = "home";
$this->sub = "";

return;
}
}
`code`

My question is, how is zp_auth going to find out in the cookie which user is logged in? I tried to remove the cookie-check, and add $_zp_loggedin = true; as well as the setcookie into the login script above where you can see $this->user = $row; , but it didn'work.

Any help is much appriciated :]
Sign In or Register to comment.