BUT wouldn't that simply pre populate the log in page ?
Sorry, I thought that's what you wanted. If you want users automatically logged in when they return to your site, this would need to take place in your authorization functions. You might have something like this:
function Validate ($uname, $pw)
{
# Code to validate user
}
function GetLogin()
{
if (isset($_SESSION['uname']) && isset ($_SESSION['pw'])) # Check for SESSION vars and use them if set
{
$uname = $_SESSION['uname'];
$pw = $_SESSION['pw'];
}
elseif (isset($_COOKIE['uname']) && isset ($_COOKIE['pw'])) # Check for COOKIE vars and use them if set
{
$uname = $_COOKIE['uname'];
$pw = $_COOKIE['pw'];
}
elseif (isset($_POST['uname']) && isset ($_POST['pw'])) # Finally, check for POST vars and use them if set
{
$uname = $_POST['uname'];
$pw = $_POST['pw'];
}
Validate ($uname, $pw);
}
HOWEVER, I would advise against using this practice. Allowing users to be authenticated without being prompted for a password poses a signifigant security risk. If you use this method, anyone can be authenticated as anyone simply by using that other person's computer. Not to mention that cookies are pretty easy to forge. I would discourage you from using this practice unless you completely trust all of your users and you know that their systems will never be used by anyone else (read: not likely). 🙂