Hi all,
I made a php application ,it is working well in mozilla but in I.E , sometimes the application gets logged out on refreshing the page ?
On refreshing the page the application gets loged out
Moderator: General Moderators
Re: On refreshing the page the application gets loged out
Re: On refreshing the page the application gets loged out
What method are you using to store whether a user is logged in? Posting a bit of your code that handles that, and how you check if a user is logged in might help too.
It may also be a browser setting too.
It may also be a browser setting too.
Re: On refreshing the page the application gets loged out
mickd wrote:What method are you using to store whether a user is logged in? Posting a bit of your code that handles that, and how you check if a user is logged in might help too.
It may also be a browser setting too.
here is the code
Code: Select all
if( isset($_POST['submit']) )
{
$usn=trim($_POST['username']);
$pass=trim($_POST['password']);
$sql= "SELECT * FROM user where username='$usn' AND password='$pass'";
$result = mysql_query($sql,$con);
$var = mysql_fetch_array($result);
$_SESSION['usertype']=$var[3];
$feildName="Username Field is required";
$feildName1="Password Field is required";
$feildName2="Enter Correct Username";
$feildName3="Enter Correct password";
if($err<>1)
{
if($var[3]==1)
{
$_SESSION['username']=$var[1];
header("location:Admin_index.php");
}
else if($var[3]==3)
{
$_SESSION['username']=$var[1];
header("location:Admin_index.php");
}
else
{
header("location:login.php");
}
}
}
//mysql_close();
?>
Last edited by Benjamin on Mon May 04, 2009 8:50 am, edited 1 time in total.
Reason: Added [code=php] tags.
Reason: Added [code=php] tags.
Re: On refreshing the page the application gets loged out
something tells me that submit isn't the issue as $_POST['submit'] will be set if you actually posted the page.
And if $_POST['submit'] weren't set, you wouldn't be getting redirected.
The issue lies in this piece of code:
I would recommend doing an echo and exit on each of those if statements above to determine which one is ringing true, and then debugging from there.
And if $_POST['submit'] weren't set, you wouldn't be getting redirected.
The issue lies in this piece of code:
Code: Select all
if($err <> 1) {
if($var[3] == 1) {
$_SESSION['username']=$var[1];
header("location:Admin_index.php");
} else if($var[3] == 3) {
$_SESSION['username']=$var[1];
header("location:Admin_index.php");
} else {
header("location:login.php");
}
Re: On refreshing the page the application gets loged out
I understand what you mean, but his piece of code shows a redirection based on $_POST['submit'] being set. And since $_POST['submit'] can only be set when the page is posted, and also since the redirects are only within the conditional if(isset($_POST['submit'])), it still means that the button is indeed set and working ok. Either way, I'm sure once he debugs this a little more he'll see the answer.