simon551 Posted June 5, 2007 Share Posted June 5, 2007 I cleared all cookies in Firefox and now my log in page doesn't work. It works in IE, but not in firefox. I don't know if this is a php (my) problem or if it is something to do with the browser. Any ideas? posting my code in case it helps <?php require_once('Connections/conn_org.php'); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['UserName'])) { $loginUsername=$_POST['UserName']; $password=$_POST['Password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "userlogin/Index_.php"; $MM_redirectLoginFailed = "userlogin/login.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_conn_org, $conn_org); $LoginRS__query=sprintf("SELECT UserName, Password FROM users WHERE UserName='%s' AND Password='%s'", get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); $LoginRS = mysql_query($LoginRS__query, $conn_org) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; //set some more cookies mysql_select_db($database_conn_org, $conn_org); $query_rsLoginDetails = ("SELECT users.UserName, users.Password, users.EmpID, tblemployees.GroupID, tblgroups.DivisionID, Managers.EmpID AS MgrID, concat(tblEmployees.EmpFName,' ',tblEmployees.EmpLName ) AS Name FROM tblemployees Inner Join tblgroups ON tblemployees.GroupID = tblgroups.GroupID Inner Join users ON tblemployees.EmpID = users.EmpID Inner Join tblemployees AS Managers ON tblemployees.TeamID = Managers.EmpID WHERE users.UserName= '$loginUsername' AND users.Password= '$password'"); $rsLoginDetails = mysql_query($query_rsLoginDetails, $conn_org) or die(mysql_error()); $row_rsLoginDetails = mysql_fetch_assoc($rsLoginDetails); $totalRows_rsLoginDetails = mysql_num_rows($rsLoginDetails); setcookie("empid", "".$row_rsLoginDetails['EmpID'] ."", time()+(60*60*24*10), "/", "", 0); setcookie("divisionid", "".$row_rsLoginDetails['DivisionID'] ."", time()+(60*60*24*10), "/", "", 0); setcookie("mgrid", "".$row_rsLoginDetails['MgrID'] ."", time()+(60*60*24*10), "/", "", 0); //end custom code, go back to dw standard login if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="login" name="login" method="POST" action="<?php echo $loginFormAction; ?>"> <table width="100%" border="0" cellspacing="0" cellpadding="6"> <tr> <td width="25"> </td> <td colspan="2" class="smallText"> </td> </tr> <tr> <td width="25"> </td> <td >USER NAME</td> <td ><input name="UserName" type="text" id="UserName" size="40"></td> </tr> <tr> <td width="25"> </td> <td >PASSWORD</td> <td ><input name="Password" type="password" id="Password" size="40"></td> </tr> <tr> <td width="25"> </td> <td > </td> <td ><input name="Login" type="submit" id="Login" value="Login"></td> </tr> </table> </form> </body> </html> Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/54206-solved-problem-with-login-page-possibly-to-do-with-cookies/ Share on other sites More sharing options...
redarrow Posted June 5, 2007 Share Posted June 5, 2007 <?php $_session_start(); <<<< must be top ok. code.... ... ... .. .. .. .. ?> you dont need all this do ya if (!isset($_SESSION)) { session_start(); } Quote Link to comment https://forums.phpfreaks.com/topic/54206-solved-problem-with-login-page-possibly-to-do-with-cookies/#findComment-268063 Share on other sites More sharing options...
simon551 Posted June 5, 2007 Author Share Posted June 5, 2007 doesn't seem to have helped. Quote Link to comment https://forums.phpfreaks.com/topic/54206-solved-problem-with-login-page-possibly-to-do-with-cookies/#findComment-268130 Share on other sites More sharing options...
simon551 Posted June 5, 2007 Author Share Posted June 5, 2007 not helpful advice redarrow. I don't know where you get the super guru status from. The problem was all in firefox. I just didn't realize that with ff, after you delete a cookie, it blocks the site from setting a cookie. Quote Link to comment https://forums.phpfreaks.com/topic/54206-solved-problem-with-login-page-possibly-to-do-with-cookies/#findComment-268499 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.