they just dont taste right.
anyone know a good recipe?
basically the login script i have is that it logs on, creates the cookie i think and then completes the login process, ive tested it by having a profile.php file where the user edits their own information that is grabbed from the sql by their username that is stored in the cookie. all this works perfectly except at the end of the login procedure i put a simple link that goes back to the index page except when the index page loads up the login thing is not remembered.
heres the code for the memberbar.php which is included in the index.php
require ("".$DOCUMENT_ROOT."/cgi-bin/connect.php");
$username = $HTTP_COOKIE_VARS['adminname'];
global $username;
$counter = 0;
$flag=0;
$result = @mysql_query("SELECT password FROM ".$membertable."");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
while ( $row = mysql_fetch_array($result) ) {
$dpass = $row["password"];
$duser = md5($HTTP_COOKIE_VARS['adminname']);
$dtotal = "$dpass$duser";
$dcookie = $HTTP_COOKIE_VARS['memberlogon'];
if ($dtotal==$dcookie) {$flag=1; $temp = "$dpass";}
}
if ($flag != 1) {
echo("<font color='#FFFFFF'><div align='center'>Welcome Guest: <a href='/login/register.php'>Register</a> or <a href='/login/login.php'>Login</a></div></font>");
}
else if ($flag == 1) {
echo("Welcome ".$username."! ( <a href='/login/profile.php' target='_blank'>Edit Your Profile</a> / <a href='".$url."index.php?login=logout'></a><s>Logout</s> )");
}
i used some of the coding to double check whether it remembered it or not but it doesn't.
before it was just:
$username = $HTTP_COOKIE_VARS['adminname'];
if ($username!==""){
// user logged in information
} else {
// guest is present
}
here is the cookie.php
$cookname = setcookie('adminname', $username, time()+315360000);
$cookpass = setcookie('adminpass', md5($password), time()+315360000);
$username=md5($username);
$cookieval = "$password$username";
$cooklogin = setcookie('memberlogon', $cookieval);
require ("".$DOCUMENT_ROOT."/cgi-bin/connect.php");
echo "Enabling cookies...<br>";
if ($cookiename == "false") {$ans = "failed";}
else {$ans = "complete";}
echo ("adminname cookie..." . $ans);
if ($cookiepass == "false") {$ans = "failed";}
else {$ans = "complete";}
echo ("<br>adminpass cookie..." . $ans);
if ($cookielogin == "false") {$ans = "failed";}
else {$ans = "complete";}
echo ("<br>adminlogin cookie..." . $ans);
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=monkey.php\">";
mysql_close($cid);
Thanks in advance!!