Jump to content

Session variable is not running in Mozilla But running in IE


Recommended Posts

Hi All,

 

When I was testing my site in mozilla I got the following issue

 

I am setting session variable in my login1.php file and accessing it in hoa.php file.

 

 

this process is working properly in IE but in MOZILLA I am not able to get the value of session. and also not able to read the value set in the child window.

 

Please help me out for this issue.

 

Thanks.

 

Regards,

 

Gagan

This is the code for login1.php in which i am using session variable it is working well in IE and mozilla

<?php

session_start();

include("application.php");

// Include the database connection details

require('dbConnection.php');

// Include common functions

require('commonFunc.php');

// Include the table handler class

require('dbHandler.class.php');

// Init and connect to database

$dbObject = new dbHandler(); $dbObject->connect();

 

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title> Login -  Ward, Damon and Posner, P.A.</title>

<meta name="keywords" content="">

<meta name="description" content="">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

 

<link href="/stylie.css" rel="stylesheet" type="text/css">

<LINK href="" type=text/css rel=stylesheet>

<LINK href="images/prov.css" type=text/css rel=stylesheet>

<style type="text/css">

<!--

.inputbox {border:1px solid #dfdfe3}

.inputbox1 {border:1px solid #dfdfe3; height:22px;}

.text{font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#333333; text-decoration:none;}

.text:hover{font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#000033; text-decoration:underline;}

-->

</style>

 

<link href="../greybox/gb_styles.css" rel="stylesheet" type="text/css" />

</head>

<body>

 

<?php

$loginId=$_POST[user];

$password=$_POST[password];

$query = mysql_query("SELECT * FROM user where userid='$loginId' and password='$password'");

if ($row1 = mysql_fetch_array($query, MYSQL_ASSOC))

{

$username = $row1['user'];

$password = $row1['password'];

if ($row1['isAdmin']=="Yes")

{

$_SESSION["login"]="T";

$_SESSION["admin"]="T";

$_SESSION["userId"]=$loginId;

?>

 

<script type="text/javascript">

<!--

browserName=navigator.appName;

browserVer=parseInt(navigator.appVersion);

if ((browserName=="Netscape" && browserVer>=7.2) || (browserName=="Microsoft Internet Explorer" && browserVer>=5.5) || (browserName=="Opera" && browserVer>=7.1) || (browserName=="Mozilla Firefox" && browserVer>=1))

version="vernew";

else

version="other";

/* Newer browser URL */

if (version=="vernew")

window.location="admin.php?login=T";

/* Other browsers URL */

else

window.location="admin.php?login=T";

//-->

</script>

 

<?php

}

 

 

else

{

 

$_SESSION["login"]="T";

$_SESSION["admin"]="F";

$_SESSION["userId"]=$loginId;

$_SESSION['user'] = $row1['user'];

$_SESSION['recNo'] = $row1['recNo'];

$row1['recNo'] =$recNo;

$_SESSION['parentCatNo '] = $row1['parentCatNo'];

 

?>

<script type="text/javascript">

<!--

browserName=navigator.appName;

browserVer=parseInt(navigator.appVersion);

if ((browserName=="Netscape" && browserVer>=7.2) || (browserName=="Microsoft Internet Explorer" && browserVer>=5.5) || (browserName=="Opera" && browserVer>=7.1) || (browserName=="Mozilla Firefox" && browserVer>=1))

version="vernew";

else

version="other";

/* Newer browser URL */

if (version=="vernew")

window.location="hoa.php?login=T";

/* Other browsers URL */

else

window.location="hoa.php?login=T";

//-->

</script>

<?php

      }

}

else

{

$_SESSION["login"]="F";

?>

<script type="text/javascript">

<!--

browserName=navigator.appName;

browserVer=parseInt(navigator.appVersion);

if ((browserName=="Netscape" && browserVer>=7.2) || (browserName=="Microsoft Internet Explorer" && browserVer>=5.5) || (browserName=="Opera" && browserVer>=7.1) || (browserName=="Mozilla Firefox" && browserVer>=1))

version="vernew";

else

version="other";

/* Newer browser URL */

if (version=="vernew")

window.location="myindex.php?login=F";

/* Other browsers URL */

else

window.location="myindex.php?login=F";

//-->

</script>

 

<?php

}

 

?>

</body>

</html>

 

 

and this is code for hoa.php in which when i am login it is showing records in  IE very well but not in Firefox

 

<?php

session_start();

$a = session_name();

$b = $_SESSION["userId"];

//echo $_SESSION["login"];

//echo $_SESSION["userId"];

if ($_SESSION["login"]!="T")

{

 

header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/myindex.php');

header("Cache-control: private");

// Include the database connection details

require('dbConnection.php');

// Include common functions

require('commonFunc.php');

// Include the table handler class

require('dbHandler.class.php');

###########################################################

// Init and connect to database

$dbObject = new dbHandler(); $dbObject->connect();

$user = new dbHandler();

$user->connect();

$userId=$_SESSION["userId"];

$recNo=$_SESSION['recNo'];

  $parentCatNo =$_REQUEST["parentCatNo "];

$query = $user->SelectAndNext("SELECT * FROM user where userid='$userId'");

?>

<link href="/stylie.css" rel="stylesheet" type="text/css">

<link href="../stylie.css" rel="stylesheet" type="text/css">

<LINK href="" type=text/css rel=stylesheet>

<LINK href="images/prov.css" type=text/css rel=stylesheet>

<!--<SCRIPT language=JavaScript1.2 src="images/stmenu.js" type=text/javascript></SCRIPT>-->

<script language="javascript1.2" src="images/stmenu.js" type=text/javascript></script>

</head>

 

<body>

 

<? include ("../includes/header.php"); ?>

 

 

<table width="725" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>

    <td colspan="3"><img src="../img/topbeam.gif" width="725" height="21"></td>

  </tr>

  <tr>

    <td width="23"  style="background-image:url(../img/lefty.gif)"><img src="../img/lefty.gif" width="23" height="10"></td>

    <td width="679" bgcolor="#FFFFFF"> <table width="679" border="0" cellspacing="0" cellpadding="0">

      <tr><td width="189" valign="top" style="background-image:url(/img/side_nav.jpg)">

        <table width="100%" border="0" cellspacing="0" cellpadding="0">

  <tr>

    <td><? include ("../includes/leftnav2.php"); ?></td>

  </tr>

</table>

</td>

        <td width="490" align="center" bgcolor="#F2F3E2"><table width="490" border="0" cellspacing="0" cellpadding="0">

          <tr>

            <td><img src="Client-Login.jpg" width="490" height="60"></td>

          </tr>

          <tr>

            <td style="background-image:url(../img/content_back.jpg)"><table width="100%" border="0" cellspacing="0" cellpadding="0">

                         

              <tr>

                <td> </td>

                <td align="center"><br><? $userId=$_SESSION["userId"];

$sqlQuery="SELECT * FROM user where userid='$userId'";

$query1 = mysql_query($sqlQuery);

if ($row = mysql_fetch_array($query1, MYSQL_ASSOC))

{ echo "<b><FONT COLOR='#40692C'>Welcome : </b> <font color='red'><b>".$row[firstName]."</b></font></FONT>"; ?>

<?php

}?></td>

              <td> </td></tr>

              <tr>

                <td> <br></td>

                <td> <fieldset>  <legend><FONT SIZE="2" COLOR="#6F7542" face="verdana"><B><I>HomeOwner Details<? echo $a,$b; ?></I></B></FONT></legend><BR>

<?php

$sqlQuery = "SELECT * FROM user where parentCatNo='".$recNo."' order by firstName ASC";

$selectedRecords = $dbObject->Select($sqlQuery);

 

// If no records selected, print message

if (!$selectedRecords)

{ echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td >There are no selected records</td></tr></table>"; }

 

while($row1=$dbObject->SelectNext())

{ // Find total products and subcategories in this category

  //$other=substr($row1['other'],40);

echo  "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";

echo " <tr><td width='3%'> </td>";

echo "<td width='38%' class='pophead'><strong>HomeOwner Name </strong></td>";

echo "<td width='30%' class='pophead'><strong>Unit # </strong></td>";

echo "<td width='29%'> </td></tr>";

echo "<tr><td class='blurb'> </td>";

echo "<td class='blurb'>".$row1[firstName]."</td>";

echo "<td class='blurb'>$row1[unit_no]</td>";

echo "<td class='blurb'> </td></tr>";

echo "<tr><td height='12' colspan='4'></td></tr>";

echo "<tr><td> </td><td class='pophead'><strong>First Notice </strong></td>";

/* echo "<td class='pophead'><strong>Foreclosure Notice </strong></td>"; */

echo "<td class='pophead'><strong>Claim Lien </strong></td></tr>";

echo "<tr><td> </td>";

echo "<td class='blurb'>$row1[first_notice]</td>";

/* echo "<td class='blurb'>$row1[lien_notice]</td>"; */

echo "<td class='blurb'>$row1[claim_lien]</td>";

echo "</tr><tr><td> </td>";

echo "<td class='pophead' colspan='3'><strong>Foreclosure Notice </strong></td>";

echo "</tr><tr><td> </td>";

echo "<td class='blurb' colspan='3'>$row1[lien_notice]</td>";

echo "</tr><tr>";

echo "<td height='12' colspan='4'></td>";

echo "</tr><tr><td> </td>";

echo "<td class='pophead' colspan='3'><strong>Notes</strong></td>";

/* echo "<td class='pophead'><strong>Other</strong></td>"; */

echo "</tr>";

echo "<tr><td> </td>";

/* echo "<td class='blurb'>$row1[foreclose]</td>"; */

echo "<td class='blurb' colspan='3'>$row1[other] </td></tr>";

echo "<tr><td> </td>";

echo "<td class='blurb'></td>";

echo "<td class='blurb'></td>";

echo "</tr>";

echo "<tr><td height='1' colspan='4' bgcolor='#999999'></td></tr>";

echo "<tr><td height='16' colspan='3' align='right'></td>";

echo "</table>";

}

 

 

echo "<table  width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td class='blurb' align='right'><a href='logout.php'><font color='red'><b>LOGOUT</b></font></a></td></tr>";

echo "</table>";

?>       

          </fieldset>  </td>

     

         

              </tr>

            </table></td>

          </tr>

          <tr>

            <td><a href="http://www.warddamon.com/"><img src="content_footer_terms.jpg" alt="return to the homepage of warddamon.com" width="490" height="25" border="0"></a></td>

          </tr>

        </table></td>

      </tr>

 

    </table>

      </td>

    <td width="23" style="background-image:url(../img/righty.gif)"><img src="../img/righty.gif" width="23" height="10"></td>

  </tr>

  <tr>

    <td colspan="3"><img src="../img/btmbeam.gif" width="725" height="21"></td>

  </tr>

</table>

<?php include ("../includes/footer.php");

session_unset();

session_destroy();

$_SESSION = array();

 

?>   

             

<p> </p>

<p> </p>

 

 

Please help me . How i can show this in Firefox also. It is very urgent .

Thanks

At the end of hoa.php, you are executing session_unset(); session_destroy(); and $_SESSION = array();. This has the effect of logging the visitor out. FF has a nasty habit of requesting a page twice. I think it is requesting hoa.php the first time and the results are probably correct, but it is requesting it a second time and at that point the visitor is not logged in and you see the results of the second request without the queries matching no rows in the database.

 

Even though the visitor is not logged in for the second request, because the code on your page continues execution after the header() redirect, you could see the output from that page and in fact the header() redirect might not be executing or the sessions might not be starting on the hoa.php page.

 

Add the following two lines immediately after the first opening <?php tag on both pages -

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

 

Every header() redirect needs an exit() statement after it to prevent the remainder of the code on your page from executing while the browser is requesting the new page.

 

And is the code to log the visitor out at the end of the hoa.php page supposed to be executed every time that page is requested or is it only supposed to be executed when the logout link is clicked?

 

 

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.