forumnz Posted January 29, 2008 Share Posted January 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/ Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 Either cookies are disabled on the browser or the domain is changing... like www.domain.com and domain.com, those are considered two different domains. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-451975 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 Its not. Please see www.foodfinder.co.nz and use the login 'sam', pass 'sam'. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-451986 Share on other sites More sharing options...
hamza Posted January 29, 2008 Share Posted January 29, 2008 ------------------------------------------------------- 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 Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452002 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 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(); Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452005 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452009 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452012 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 Help? Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452046 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 Put the following in the login-exec.php file, after the session_start(), and post what you get - echo "<pre>"; var_dump($_POST); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452056 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 array(4) { ["refer"]=> string(0) "" ["login"]=> string(5) "sam" ["password"]=> string(5) "sam" ["Submit"]=> string(5) "Login" Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452057 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452059 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452060 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 Using IE and sam/sam, it logged in for me. The POST data is correct. Therefore, it is probably something specific with your browser, such as a corrupt cookie or cookies are not accepted for that domain. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452062 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 May I ask, how did you know you were logged in? Sam. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452064 Share on other sites More sharing options...
PFMaBiSmAd Posted January 29, 2008 Share Posted January 29, 2008 I tried both the Business Owners and Customers "Sign in" link and after entering sam/sam, the url went to - http://www.foodfinder.co.nz/?l=y and the prompt in the yellow/Business Owners or red/Customers block on the left-hand bottom of the screen changed to "Logout" Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452068 Share on other sites More sharing options...
forumnz Posted January 29, 2008 Author Share Posted January 29, 2008 Ok thanks. I guess I'll leave it and deal with any problems as they come. Thanks a lot, Sam. Quote Link to comment https://forums.phpfreaks.com/topic/88323-solved-users-with-ie-and-sessions-help/#findComment-452069 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.