Alright, so now I'm working on the actual authentication script for my website, and I'm using cookies. I tested out cookies, and I had them working, but now when I try it, it isn't working.
Here is my code:
while ($result=mysql_fetch_array($query)) {
//loop through the usernames and passwords
if (($new_user == $result['username']) && ($new_password == $result['password'])) {
//if the user matches a user in the database, setup the cookies
setcookie('user_name', $new_user, time()+3600);
setcookie('password', $new_password, time()+3600);
//create the session variables
$_SESSION['user_name'] = $_COOKIE['user_name'];
$_SESSION['password'] = $_COOKIE['password'];
print_r($_SESSION);
print_r($_COOKIE);
//create normal variables
$user = $_SESSION['user_name'];
$password = $_SESSION['password'];
//end the loop
break;
}
}
I basically just have it looping through a mysql query looking to match a username and password, and then it puts it into a cookie, then a session cookie and a variable. It wasn't working, so I used print_r to view what's in the $_SESSION and $_COOKIE global array, but there was nothing in it.
Any thoughts on why exactly it doesn't work?