Here are the codes for 3 files I am using to set a cookie. Please scroll down after the code for my problem.
Login_form.html
<?php
include 'header.html';
?>
<form action="testing5.php" method="post" name="" id="">
<table width="50%" border="0" align="center" cellpadding="4" cellspacing="0">
<tr>
<td width="22%">Username</td>
<td width="78%"><input name="username" type="text" id="username"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="password" type="password" id="password"></td>
</tr>
<tr>
<td>Set Cookie.</td>
<td><input type="checkbox" name="remember"></td>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
include 'footer.html';
?>
testing5.php
<?php
$cookie_remember = $_POST['remember'];
$username = $_POST['username'];
$password = $_POST['password'];
if($cookie_remember == "on") {
include 'testing2.php';
echo "It's on.";
exit();
} else {
echo "It's off.";
}
?>
testing2.php
This setup is just me trying to figure out how to pass cookies, I will not be using the username and password in the final cookie. Login_form.html sends the value of 'username' 'password' and 'remember' to testing5.php. Testing5.php calls testing2.php, where the code for setting the variables to MD5 and setting the cookie are. With this setup, the cookie placement works, but when I add the contents of testing2.php to this area after the IF statement, replacing the include, it does not work. Here is what I would like it to look like.<?php
$cookieuser = md5($username);
$cookiepass = md5($password);
setcookie("booger", "$cookieuser", time()+3600*24*100, "", ".kornmonkie.com", 0);
setcookie("booger2", "$cookiepass", time()+3600*24*100, "", ".kornmonkie.com", 0);
?>
testing5.php
I have been getting the echo of "It's on," but nothing is being written into the cookie. I know cookies are sent in the headers, so maybe I am screwing up there? Any help would be appreciated.<?php
$cookie_remember = $_POST['remember'];
$username = $_POST['username'];
$password = $_POST['password'];
if($cookie_remember == "on") {
$cookieuser = md5($username);
$cookiepass = md5($password);
setcookie("booger", "$cookieuser", time()+3600*24*100, "", ".kornmonkie.com", 0);
setcookie("booger2", "$cookiepass", time()+3600*24*100, "", ".kornmonkie.com", 0);
echo "It's on.";
exit();
} else {
echo "It's off.";
}
?>


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks