Forum Moderators: coopster

Message Too Old, No Replies

session variables and firefox

         

bysonary

9:29 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



I have been tinkering with a login script, it suddenly doesn't work in my firefox browser on my machine, it works fine in IE on my machine but wont in firefiox, and probably has something to do with session variables.

Are there any particular settings in firefox that need to changed/modified in order for session varialbes to work?

I recently just updated to fireforx 2.0.0.4, so could that also be part of the issue?

just a bit worried here that my php scripts are now not going to work in firefox, the way i have it is i have a file called auth.php that checks if $_SESSION['Authenticated'] is true or not, if it is then it will load the page, if not it will redirect to a login page, whats happening in firefox is even as the correct username and password are entered it is saying "this page requires login" however in IE it goes on to load the correct page.

any help?

barns101

9:47 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



It may be that Firefox is not accepting a session cookie.

bysonary

10:53 pm on Jun 4, 2007 (gmt 0)

10+ Year Member



as far as i can see i have firefox all setup to accept cookies of any type, so how can i go about fixing this issue?

plus it also isnt working for a friend of mine and he uses firefox

barns101

9:54 am on Jun 5, 2007 (gmt 0)

10+ Year Member



Maybe it's a caching problem? I have found that Firefox sometimes shows cached pages instead of the latest version (I can't find anywhere to edit the preferences, like you can with IE).

You can post the code for us to check.

bysonary

10:53 am on Jun 5, 2007 (gmt 0)

10+ Year Member



Ok there are two files, auth.php that i include at the top of pages i want to be authenticated and login.php which is processed by the form. The two form fields for the username and password are called fpass and fuser, here is the code.

auth.php


<?php
session_start();
if($_SESSION['Authenticated']!= true)
{
header('Location: http://example.co.uk/bin/loginform.php?e=You%20need%20to%20login%20to%20view%20this%20page');
//echo "not logged in, this page is protected";
exit();
}
?>

login.php


<?php
session_start();
include '/home/www/mysite/lib/dbcon.php';
if(isset($_POST['fuser']) && $_POST['fpass'])
{
$user = mysql_real_escape_string($_POST['fuser']);
$pass = mysql_real_escape_string($_POST['fpass']);

$query = "SELECT * FROM user WHERE username='$user' AND password='$pass'";
$result = mysql_query($query) or die("Unable to verify user because : " . mysql_error());

if(mysql_num_rows($result)!= 0)
{
$_SESSION['Authenticated'] = true;
//echo "Logged in";
header('Location: http://www.example.co.uk/bin/logs.php');
}
else
{
header('Location: http://example.co.uk/bin/loginform.php?e=Invalid%20Username%20and/or%20password');
//echo "not logged in wrong username and password";
}
}
else
{
//echo "not logged in, you didnt enter a username and password";
header('Location: http://example.co.uk/bin/loginform.php?e=Please%20enter%20a%20username%20and/or%20password');
}
mysql_close($dbc);
?>

This code has worked previously i took from other code i had written about 6 weeks ago and i know that it worked then so cant imagine why it wont work now.

The problem I am having is that any page with auth.php included at the top always asked me for a username and password, so the session variable Authenticated isnt being remembered accross a few pages.

any help greatly appreciated.

Thanks

ChrisW

[edited by: eelixduppy at 11:55 am (utc) on June 5, 2007]
[edit reason] delinked URLs [/edit]

barns101

11:43 am on Jun 5, 2007 (gmt 0)

10+ Year Member



I can't spot any problems with the code. If it's only the newest version of Firefox that's having the issues, it sounds like it's most likely a browser setup problem.

bysonary

1:37 pm on Jun 5, 2007 (gmt 0)

10+ Year Member



thing is if you see my code if i comment out the header location part of the code and uncomment the echo "Logged in"; part it works, it only seems to mess up when moving to a page that has the auth check included at the top, strangely it works fine in IE for me and fine in IE for a friend of mine. My friend also uses the latest version of firefox and it doesn't work for him either, however he is also a php programmer and he has similar sort of login script code and his script works fine for him in fiirefox (hes running php locally, I am testing on a remote server).

Could it be my web host limiting something? I suppose that doesnt explain why IE works fine but FFox doesn't, strange this i just cant get it to work :-(