Simple login form with cookies

From: Date: Mon, 06 Jul 2009 04:03:34 +0000
Subject: Simple login form with cookies
Groups: php.general 
Request: Send a blank email to php-general+get-294915@lists.php.net to get a copy of this message
Hello everyone, I am trying to create a PHP login script using cookies but am having some troubles. Here is my setup index.php -> authenticate.php -> admin.php I want a login form on index.php that allows me to login with my username and password and then passes $_POST['username'] and $_POST['password'] to authenticate.php Then authenticate.php authenticates against a database of allowed users (Which I already have setup and it works fine), if a valid user has entered the correct information then admin.php is loaded... header("location:admin.php"); ...the admin.php code would look something like the following.. Code: [Select] <?php if (isset($_COOKIE['username'])) { echo "success!"; } else { echo "Failure"; } ?> So basically I think I need to create a cookie from index.php OR authenticate.php and then pass the information to admin.php. I set the cookie like this... setcookie("Admin", $username); Which file(index.php OR authenticate.php) do I create the cookie and how do I access the information in the cookie on admin.php?

« previous php.general (#294915) next »