Jump to content

Session problem with Firefox/Moz clients


z0mb1

Recommended Posts

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  ???

Link to comment
Share on other sites

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  :-\

 

Link to comment
Share on other sites

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!!!

 

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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.

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.