I am trying to add remember me option to a membership system ..
I have managed to get the cookie writen fine using:
Code: Select all
<?
include 'db.php';
$alias = $_POST['alias'];
$password = $_POST['password'];
if ((!$alias) || (!$password)) {
echo "<center><font class=\"txt\">Please enter ALL of the information!</font></center><br><br>";
include 'login_form.php';
return;
}
$sql = mysql_query("SELECT * FROM users WHERE alias='$alias' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if ($login_check > 0) {
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
session_register('userid');
$_SESSION['userid'] = $userid;
session_register('alias');
$_SESSION['alias'] = $alias;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
if (isset($_POST['rememberme'])){
setcookie("alias", $alias, time()+60*60*24*100, "/");
setcookie("password", $password, time()+60*60*24*100, "/");
}
mysql_query("UPDATE users SET last_login=now() WHERE userid='$userid'");
header("Location: index.php?pages=login_success");
}
} else {
echo "<center><font class=\"txt\">You could not be logged in, Either the username and password do not match or you have not validated your membership.<br><br>Please try again!<br><br></font></center>";
include 'login_form.php';
}
?>I am having trouble with incorporating it into the site so if a user has a cookie set, when they come to the site (index) they are automatically logged in and see all the their options depending on there user rights.
I am using the header footer layout on the site, no mater what I try when you goto the site the index page just hangs.
Thanks