Jump to content

[SOLVED] Users with IE and sessions help


forumnz

Recommended Posts

Hi, my site uses sessions for logging in etc. On Firefox it works fine and everything, but on IE it doesn't.

 

Example: My menu is meant to say "Login" if not logged in or "Logout" if you are. On IE it always says "Login" (or Sign In rather).

 

I know PHP is a server executed things, so I don't know why it isn't working - maybe something wrong with the sessions?

 

Please let me know what you need to see (code wise), and I'll post it.

 

Thanks for your help everyone!

Sam.

Link to comment
Share on other sites

-------------------------------------------------------

There is javascript error it was showing in your werbsite.

-------------------------------------------------------

 

And always use $_SESSION[] for assigning and recieving

session's;

It will not problem you try it

 

 

Link to comment
Share on other sites

This is what I have at the top of my index.php page:

 

<?php
//Start session
session_start();
echo $_SESSION['SESS_MEMBER_ID'];
?>

 

I also have some code in my menu:

 

<?php if(!isset($_SESSION['SESS_MEMBER_ID']) || $_SESSION['SESS_LEVEL_ID'] != '1'){ echo "<a class=\"one\" href=\"/Login.php\">Sign in</a>"; } else { echo "<a class=\"one\" href=\"/Logout.php\">Logout</a>";}?>

 

Can you see anything wrong with these?

 

Also, this is the code that logs the user in:

 

Snippet:

$_SESSION['SESS_MEMBER_ID'] = $member['id'];
		$_SESSION['SESS_LEVEL_ID'] = $member['lvl'];
		session_write_close();

Link to comment
Share on other sites

Usually when a page functions differently in different browsers, it is because the html markup is invalid and one browser renders it correctly and the other one does not. So, it is likely that your login form is invalid html.

 

For anyone here to be able to help with what your code is doing, you would need to post it.

Link to comment
Share on other sites

The login-exec.php:

 

<?php
//Start session
session_start();

include('connectdb.php');

//Sanitize the value received from login field
//to prevent SQL Injection
if(!get_magic_quotes_gpc()) {
	$login=mysql_real_escape_string($_POST['login']);
}else {
	$login=$_POST['login'];
}

//Create query
$qry="SELECT id, lvl, active FROM ffusers WHERE login='$login' AND passwd='".md5($_POST['password'])."' AND active='1'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
	if(mysql_num_rows($result)>0) {
		//Login Successful
		session_regenerate_id();
		$member=mysql_fetch_assoc($result);
		$_SESSION['SESS_MEMBER_ID'] = $member['id'];
		$_SESSION['SESS_LEVEL_ID'] = $member['lvl'];
		session_write_close();
		$url=$_POST['url'];
		if($url != "")
		{
		header("location: http://www.foodfinder.co.nz/" . $url);
		}
		else
		{
		header("location: http://www.foodfinder.co.nz/?l=y");
		}
		exit();
	}else {
		//Login failed
		header("location: Login.php?m=fail");
		exit();
	}
}else {
	die("Query failed");
}
?>

 

Is that what you wanted?

 

Please let me know if you can or can't help.

 

Thanks, Sam.  ;)

Link to comment
Share on other sites

When I tried sam/sam before you added the var_dump code, using IE, it logged in.

 

You will note that with your browser, the length of "sam" is 5 bytes.

 

When I just tried again using IE and FF, the length is correct, 3 bytes.

 

Something in your page or your browser is sending the form data with a length that is not correct. I suspect it might be adding white space.

 

Use the trim() function on the data from the form to see if that corrects the problem.

Link to comment
Share on other sites

Oh sorry its meant to be as below. I used a diff login and then changed it for posting on here.

 

This is as it is:

 

array(4) {

  ["refer"]=>

  string(0) ""

  ["login"]=>

  string(3) "sam"

  ["password"]=>

  string(3) "sam"

  ["Submit"]=>

  string(5) "Login"

}

 

Thanks for your help - any ideas?

 

Sam.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.