Hello, I am using cookies along with sessions for a login script, and I had the cookies working fine at one point but the sessions werent working correctly, so I fixed the sessions and then my cookies wouldn't work. Please Help.
First Page:
<?php
if ($COOKIE2=="true")
{
$checkbox = "checked";
} else {
$checkbox= " ";
}
?>
<center>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><font face="arial" size="2"><b>Username:</b></font></td>
<td><input type="text" name="username" value="<?php echo $COOKIEUSERNAME; ?>"></td>
</tr>
<tr>
<td><font face="arial" size="2"><b>Password:</b></font></td>
<td><input type="password" name="password" value="<?php echo $COOKIEPW; ?>"></td>
</tr>
<tr>
<td>_</td>
<td><font face="arial" size="1"><b>Save Password:</b></font> <input type="checkbox" <?php echo $checkbox; ?> name="cookie" value="yes"></td>
</tr>
<tr>
<td>_</td>
<td><input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</center>
Second Page:
<?php
setcookie("COOKIEUSERNAME", $username, time() + 31536000);
if ($cookie=="yes") {
setcookie("COOKIEPW", $password, time() + 31536000);
$COOKIE1 = "true";
} else {
setcookie("COOKIEPW", "", time() + 31536000);
$COOKIE1 = "false";
}
setcookie("COOKIE2", $COOKIE1, time() + 31536000);
session_start();
session_register("username");
session_register("password");
?>
it doesnt set the cookie at all even the first $COOKIEUSERNAME 🙁