Class: backend.php
<?php
class login_lib
{
function login($username, $password)
{
if (!$username || !$password)
{
return $this->error[14];
}
else
{
if (!eregi(\"^[[:alnum:]_-]+$\", $username))
{
return $this->error[3];
}
if (!eregi(\"^[[:alnum:]_-]+$\", $password))
{
return $this->error[7];
}
mysql_connect($this->server, $this->db_user, $this->db_pass);
mysql_select_db($this->database);
$query = mysql_query(\"select id from login where username = \'$username\' and password = \'$password\'\");
$result = mysql_num_rows($query);
mysql_close();
if ($result < 1)
{
return false;
}
else
{
list ($id) = mysql_fetch_row($query);
$hash = base64_encode($this->keyED($this->encrypt($this->keyED($username, $this->key1), $this->key2), $this->key3));
setcookie(\"sometext\", \"$username:$hash:$id\", time()+3600);
return 2;
}
}
}
}
$login_lib = new login_lib;
?>
The: login.php
<?
require(\"backend.php\");
if (!$username || !$password) {
include(\"html/login_notext.htm\");
}
$login = $login_lib->login($username, $password);
if (!$login) {
include(\"html/login_error.htm\");
}
else {
include(\"html/login_done.htm\");
}
?>
Everything works fine, except the rule:
<?
setcookie(\"sometext\", \"$username:$hash:$id\", time()+3600);
?>
He doesn\'t create a cookie!
When I change the line (login.php):
<?
$login = $login_lib->login($username, $password);
?>
In this:
<?
$login = $login_lib->login($username, $password);
exit;
?>
Then he will create the cookie.
Why not imiditly? It to work with the test later!
Who can help me?
Tnx,
Wouter