z0mb1 Posted February 8, 2008 Share Posted February 8, 2008 I think that PHP sessions and Firefox are about to drive me crazy. I was attempting to demonstrate how easy it is to use PHP sessions but my code doesn't work in Firefox. I have EXACTLY the same files on 2 different unix Apache servers, one with PHP4, one with PHP5. I have copied the same code to an IIS server with PHP 5 The example works with IE5.5, 6 and 7 and Opera 9 clients but for reasons that are beyond me does not work with Firefox or Mozilla clients. Yes, cookies are on in the Mozclients and I have tried restarting the Mozclients and tried several Moz clients. Please feel free to try the examples... PHP 4 on Apache http://staffweb.cms.gre.ac.uk/~mk05/session/index.php PHP5 on Apache http://stuweb.cms.gre.ac.uk/~mk05/session/index.php PHP5 on IIS http://cms-stu-iis.gre.ac.uk/mk05/session/index.php You can see the sources by appending .txt to the .php filenames on the Apache servers (e.g. index.php.txt). These are links not copies so you see exactly the same source. What you will observe is that $_SESSION stores literals but not variables. The thing that really gets me is why it refuses to work in Mox clients. This should be almost completely independent of the client. Puzzled - you bet ??? Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/ Share on other sites More sharing options...
revraz Posted February 8, 2008 Share Posted February 8, 2008 Post the code, appending .txt doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462121 Share on other sites More sharing options...
nethnet Posted February 8, 2008 Share Posted February 8, 2008 Appending .txt worked to see the source... and I don't exactly understand why it's not working for you when it works for me in both Opera and Firefox. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462125 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 http://staffweb.cms.gre.ac.uk/~mk05/session/index.php.txt etc. reveals the sources - only from the apache servers, not iis Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462138 Share on other sites More sharing options...
revraz Posted February 8, 2008 Share Posted February 8, 2008 Maybe remove session_destroy(); // initialise session Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462139 Share on other sites More sharing options...
revraz Posted February 8, 2008 Share Posted February 8, 2008 I don't even see any sessions being set on that page. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462144 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi nethnet I am boggled On my local Firefox (2.0.0.12) I can kill the browser, delete all cookies and I don't see the uName and uPasswd persist, although foo does. If I remote to another desktop with another Firefox (2.0.0.11) or Mozilla (1.7.10) I still do not see uName and uPasswd values on the activate.php page Everything works in other browsers on other desktops. If you are seeing this work and I don't mystery deepens further still :-\ Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462149 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi revraz The session_destroy() works fine, removes other session garbage from experiments. Removing it doesn't make things work. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462151 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi revraz look at the next page register.php to see the allocation to $_SESSION some of these allocations are lost on moving forward to activate.php but not all Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462153 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi all I wonder if there is some confusion POST input from index.php is passed to register.php This input is assigned to SESSION vars in register.php register.php ends with print_r $_SESSION to show what is in there enter an key in register.php and submit the key POST'ed to activate.php but the SESSION loses the variable assignments (uName & uPasswd) curiously it does not lose the literal assignment (foo) and only with Moz clients!!! Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462160 Share on other sites More sharing options...
revraz Posted February 8, 2008 Share Posted February 8, 2008 Just post the code here that you are referring to. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462162 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi revrez I'm attempting to avoid clutter but if you insist index.php <?php error_reporting(E_ALL); // suppress warning messages session_start(); // initialise session session_destroy(); // initialise session ?> <?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Session Test - Apply</title> <meta name="Author" content="" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="" rel="stylesheet" type="text/css"/> <style type="text/css"></style> </head> <body> <h1>Registration Form</h1> <form method="post" action="register.php"> <p> User Name : <input type="text" name="uName" value="" size="20" maxlength="40"/><br /><br /> Password : <input type="password" name="uPasswd"/><br /><br /> <input type="submit" name="regSubmit" value="Submit"/> </p> </form> </body> </html> register.php <?php error_reporting(E_ALL); // suppress warning messages session_start(); // initialise session ?> <?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb"> <head> <title>Session Test - Register</title> <meta name="Author" content="mk05@gre.ac.uk" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="" rel="stylesheet" type="text/css"/> <style type="text/css"></style> <script type="text/javascript"><!-- --></script> </head> <body> <h1>Registration</h1> <p> Thank you for registering<br /> Please check your email to get your secret key </p> <form method="post" action="activate.php"> <p> Secret key : <input type="text" name="secretKey" value="" size="20" maxlength="40"/><br /><br /> <input type="submit" name="activate" value="Submit"/> </p> </form> <p> User name is <?php echo $_POST['uName'] ?> <br /> Password is <?php echo $_POST['uPasswd'] ?> </p> <p>SESSION contains</p><pre> <?php $_SESSION['uName'] = $_POST['uName']; $_SESSION['uPasswd'] = $_POST['uPasswd']; $_SESSION['foo'] = 'fufu'; print_r($_SESSION); ?> </pre> <p><a href="register.php" title="">reload this page</a></p> </body> </html> activate.php <?php error_reporting(E_ALL); // suppress warning messages session_start(); // initialise session ?> <?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb"> <head> <title>Session Test - Activate</title> <meta name="Author" content="mk05@gre.ac.uk" /> <meta name="Keywords" content="" /> <meta name="Description" content="" /> <link href="" rel="stylesheet" type="text/css"/> <style type="text/css"></style> <script type="text/javascript"><!-- --></script> </head> <body> <h1>Activate</h1> <p>You sent by POST<br /> Secret : <?php echo $_POST['secretKey'] ?> </p><p> In the SESSION are<br /> Name : <?php echo $_SESSION['uName'] ?><br /> Password : <?php echo $_SESSION['uPasswd'] ?> </p> <p>POST :</p> <pre><?php print_r($_POST) ?></pre> <p>SESSION :</p> <pre><?php print_r($_SESSION) ?></pre> <p> <a href="index.php">Back to the begining</a> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462170 Share on other sites More sharing options...
z0mb1 Posted February 8, 2008 Author Share Posted February 8, 2008 Hi nethnet If you are seeing uName and uPasswd values persist to activate.php with a Moz client can you tell me something about your platform and client version? TIA ABW Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462191 Share on other sites More sharing options...
z0mb1 Posted February 9, 2008 Author Share Posted February 9, 2008 OK - stand by for the weird freakshow Completely bugged out by this and unable sleep I have eventually solved the problem... In register.php comment out the line <link href="" rel="stylesheet" type="text/css"/> Still no cigar for me because quite why an empty <link> href attribute value should cause problems with Firefox remains an outstanding question. A more pressing question is who do I report this bug to? PHP or Mozilla? I still have no idea as to the possible mechanism for this behaviour. Time to fire up a proxy and dig deeper. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462293 Share on other sites More sharing options...
PFMaBiSmAd Posted February 9, 2008 Share Posted February 9, 2008 Turn off register globals (I am not a betting man, but I will bet they are on) or use unique names for each variable/array index. When register globals are on same name program/post/get/cookie/session variables overwrite each other depending on the order they are populated. Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462299 Share on other sites More sharing options...
revraz Posted February 9, 2008 Share Posted February 9, 2008 Why would you even have a stylesheet href without a link? Quote Link to comment https://forums.phpfreaks.com/topic/90126-session-problem-with-firefoxmoz-clients/#findComment-462381 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.