I deleted the code and retyped it. It worked fine for 2 days. Now, today, no cookie is being set again. I double checked and there is no white space, and no output prior to setting the cookie. To set the cookie, I have used:
Code: Select all
setcookie("wbclothes",$user[0],(time()*60*60*24)); (worked for 2 days)
setcookie("wbclothes",$user[0],(time()*60*60*24),"/");
setcookie("wbclothes",$user[0],(time()*60*60*24),"/","www.domain.com"); (worked for one day)
I also took out the () around time with mixed results. I also did a cut and paste from W3C for sh!ts and giggles with no luck.
Here is the code is the entire code:
Code: Select all
<?
$_POST['action'];
//Begin Login
if ($action=="login") {
include "include/dbconnect.php";
$uname=trim($_POST['un']);
$pword=trim($_POST['pw']);
if (($uname!="")||($pword!="")) {
$secureit='94541';
$pword=sha1($securit.trim($pword));
$qPASS="SELECT * FROM cusers WHERE uname='$uname' AND upass = '$pword' AND active = '1'";
$qrhPASS=mysql_query($qPASS,$link);
$countPASS=mysql_num_rows($qrhPASS);
if ($countPASS==1) {
$user=mysql_fetch_row($qrhPASS);
setcookie("wbclothes",$user[0],(time()*60*60*24));
$login=1;
} else if ($countPASS==0) {
$error=1;
$errorTXT="Invalid Username or Password";
} else {
$error=1;
$errorTXT="An error has occured. The site administrator has been contacted regarding this error. \n
Please call customer service at (800) 707-9692 to complete your request.";
}
} else {
$error=1;
$errorTXT="Invalid Username or Password";
}
}
//End Login
$URLreferer=parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if ($URLreferer=="") {
} else if (($URLreferer=="domainname.com")||($URLreferer=="www.domainname.com")){
} else {
header("Location: http://www.domainname.com/?popLogin=true");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link href="include/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="include/jquery.js"></script>
<script type="text/javascript" src="include/thickbox.js"></script>
<? if ($login==1) { ?>
<script language="javascript" type="text/javascript">
setTimeout(removeLogin(),500);
function removeLogin() {
parent.tb_remove();
parent.location.reload(1)
}
</script>
<? } ?>
</head>
<body>
<div id="formArea">
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<p><strong>Account Login</strong></p>
<p align="left">To log into your account, please enter your user name and password. If you have forgotten your user name and/or password, please <a href="forgot_login.php">click here</a>. If you do not have a user name, please <a href="register.php">click here</a> to register for an account. </p>
</div></td>
</tr>
</table>
<form action="login.php" method="post" enctype="application/x-www-form-urlencoded" name="loginForm" id="loginForm">
<div id="error" class="error" align="center"><? if ($error==1) echo $errorTXT; ?></div>
<table width="300" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td width="120" align="right">Username: </td>
<td><input name="un" type="text" id="un" /></td>
</tr>
<tr>
<td align="right">Password:</td>
<td><input name="pw" type="password" id="pw" /></td>
</tr>
</table>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><span class="breadcrumbs">
</td>
</tr>
<tr>
<td align="center"><input name="action" type="hidden" id="action" value="login" />
<input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>
<br />
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><a href="forgot_login.php">Forgot Username</a> | <a href="forgot_login.php">Forgot Password</a> | <a href="register.php">Register for an Account</a> </td>
</tr>
</table>
</div>
</body>
</html>
I should also mention that the login form is being brought in as an iframe in a thickbox layer.
I have tried FF, IE, and Safari with no luck. What throws me for a loop is that when I get it to work, it will work for a day or two, and then the page will stop working when I have not touched the code.
