I didnt bother reading the rest of the thred, but try this (not code)
have the login page...
in the validation page, check the values in the mysql db, and if the user is indeed a registered user, define the $_POST var like:
$username = $_POST['username'];
then set the cookie:
setcookie("is_logged_in_cookie", $username, time()+606024);
that will make a cookie named "is_logged_in_cookie" with the username inside it, and it will expire in a day. you also may want to set the domain name in the function too, so it will be harder for malicious users to forge the cookie.
Now, on a page that checks to make sure the user has the cookie, do this:
if(isset($_COOKIE['is_logged_in_cookie'])){
that will make sure the cookie is set, then right after that, define the user name:
$usrname = $_COOKIE['is_logged_in_cookie'];
and then do a mysql query to make sure that name is in the database using the $usrname var. and if the name is not in the database, set the cookie to be expired and a null value just in case the user tried to forge the cookie, and give an error. if the user is in the database, serve the page content you wanted to give to the logged in user.
Hope this helped.