I have a little login script thats gets placed into the page through a CDS... it looks something like this:
login.php
global $uSession;
// post if exists
$pLogin = getPostVar('login','');
$pPassword = getPostVar('password','');
$rememberme = getPostVar('rememberme', 0);
if (!$uSession['logged']){
if ($pLogin == '') $pLogin = $_COOKIE['login'];
if ($pPassword == '') $pPassword = $_COOKIE['password'];
}
// error message
$error = '';
//Login form submited
if ($pLogin && $pPassword) {
$query = '
SELECT id, login, status, firstName, lastName, email
FROM _users
WHERE login="' . addslashes($pLogin) . '" AND password=md5("' . addslashes($pPassword) . '")';
$data = $suSQL->queryRow($query);
// Data not entered or user doesn't exists //
if (!$data || !$pPassword)
$error = ' <font color="darkred"> - incorrect</font>';
else
if(!$data['status']){
echo '<script language="JavaScript">alert(inactive!!!!!);</script>';
header("Location: [url]http://www.home.com[/url]");}
else {
$suSQL->query('UPDATE _users SET lastLogin=now() WHERE id='.$data['id']);
$uSession['uid'] = $data['id'];
$uSession['firstName'] = $data['firstName'];
$uSession['lastName'] = $data['lastName'];
$uSession['email'] = $data['email'];
$uSession['logged'] = 1;
$subscriber = $suSQL->queryValue('SELECT IF(users_id, 1, 0) subscriber FROM _subscribers WHERE users_id='.$data['id']);
$uSession['subscriber'] = $subscriber;
if ($rememberme == 1){
setcookie("login", $pLogin, time() + 60*60*24*365);
setcookie("password", $pPassword, time() + 60*60*24*365);
}
}
}
when I submit the login info (and check the remember me checkbox) the user gets logged in and the cookie is set.
BUT
once I go to another page on the site... wether it be the login page or any other page (all of which have login.php in them) the cookie gets cleared!
anybody know why this happens? My registration page uses cookies, too and those gets saved!