After some careful consideration I have decided to convert from sessions to cookies. I am however having a bit of trouble just getting started. I have a password page that should accept only one password, set the cookie and move on to the next page. But instead it just sits there doing nothing or it just loops back to the password page again. Can some please have a look at my code to see where I have made my error?
Thanks,
<?php
ob_start();
if (isset($_COOKIE['nccpass1'])){
header("location: ../general.php");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Security</title>
<?php
include ('..\includes\cssinclude.php');
include ('..\includes\meta.php');
?>
</head>
<body>
<div id="content">
<?php
include ('..\includes\outline.php');
?>
<p>
<div align="center">
<h2 class="style1"><font color="#FF0000">NCC PASSWORD PROTECTED AREA </font> </h2>
<p class="style1"><img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"> <img src="../images/lock.jpg" width="68" height="81"></p>
<h3><strong>You must enter a password to continue. </strong>
</h3>
</p>
<form method="post" action="password_cs.php">
<div align="center">
<center>
<table border="0" cellpadding="5" cellspacing="0">
<tr>
<td>
</td>
<td><input name="password" type="password" size="30" /></td>
</tr>
</table>
</center>
</div>
<p align="center">
<input type="submit" name="Submit" value="Enter my password" class="button_colour" /></p>
</form>
<?php
if (isset($_POST['password'])) {
if ($_POST['password'] == "password123") {
setcookie('nccpass1', time()+600);
header("location: ../General.php");
} else {
include('error_p.htm');
}
}
?>
</body>
</div>
</html>