I have a login with username and password on my index.html page, and I have created 2 cookies to remember these values on a user's computer. Everything works well except that if the cookies are set, the user doesn't need to login to get to any page in the site.
I thought this would be resolved by setting a particular directory path to the cookies ("/index.html") and it did solve it, except that now the cookies only work if they type in the full url ("http://www.domainname.com/index.html") as opposed to working on that same page no matter how it's called (like the far more commonly used "http://www.domainname.com").
How do I get my cookies to work ONLY ON the index page and also ALWAYS ON the index page no matter how it's called?
Here's my code:
<?php
$password = $_COOKIES['password'];
$username = $_COOKIES['username'];
?>
<form method="post" action="success.php">
<div align="center"><center><table border="0" cellspacing="0">
<tr>
<td><strong><font face="Arial" size="2">Username:</font></strong> </td>
<td><input type="text" name="username" value='<?php echo $HTTP_COOKIE_VARS["username"]; ?>' size="20"></td>
</tr>
<tr>
<td><font face="Arial" size="2"><strong>Password:</strong></font> </td>
<td><input type="password" name="password" value='<?php echo $HTTP_COOKIE_VARS["password"]; ?>' size="20"></td>
</tr>
</table>
</center></div><font face="Arial" size="2"><p><input type="submit" value="Submit"> <input type="reset"
value="Reset"></p>
</form>
....And on the success page....
<?php
$cookie_life = time() + 31536000;
setcookie('password', $password, $cookie_life, '/index.html');
setcookie('username', $username, $cookie_life, '/index.html');
?>
Thanks for all your help!