Jump to content


Photo

Session info changes on Refresh


  • Please log in to reply
5 replies to this topic

#1 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 28 February 2006 - 11:17 PM

When I refresh certain pages, my session variables change value. Can anyone shed some light on this for me?

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 28 February 2006 - 11:26 PM

Odd...unless, you haven't registered the session variables. :-)

Any chance you can paste some code?
PHP Ninja

#3 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 28 February 2006 - 11:29 PM

<?
//Session Starting
session_start();

include("include/connection.php");

$sql_1    = "SELECT *  
        FROM users
        WHERE first_name = '$_POST[username]' and password = '$_POST[password]'
        ";

$qry_auth_result = mysql_query($sql_1, $connection) or die("Could not execute Authentication Query.");

$num = mysql_num_rows($qry_auth_result);

while ($row = mysql_fetch_assoc($qry_auth_result)) {
        $permission = $row [permission];
        $first_name = $row [first_name];
        $user_tag = $row[user_tag];
    }

$_SESSION[permission] = $permission;
$_SESSION[first_name] = $first_name;
$_SESSION[user_tag] = $user_tag;

This is where I login and register variables

<?
//Session Starting
session_start();

    if ($_SESSION[valid] != "yes") {    
        header("location:http://www.andybourdeau.com/nascar");
            exit;
    }

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<title>Fantasy Nascar</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="en-us" />
<link href="styles/nascarlayout.css" media="screen" rel="stylesheet" type="text/css" />
<style>
body {    
    background-color: white;
    /*background-image:url(images/greytexture.jpg);*/
    font: 100% verdana, helvetica, "trebuchet ms", arial;
    behavior: url(css/csshover.htc);
    }
* {margin:0; padding:0;}
</style>
</head>
<body>
<div id="mainwrap">
    <div id="titlebar">
        <h1>Fantasy Nascar</h1>
    </div>
    <div><!--Menu Bar Here-->
        <? include("include/nascar_drop_menu.php"); ?>
    </div>
    <div id="contentarea" class="clearfix">
        <div id="left_column">
            <div class="table_heading">
                <h5><? echo $_SESSION[first_name]; ?> Drivers</h5>
            </div>
            <div class="table_body">
                <p align="center"><? include("include/display_drivers.php"); ?></p>
                <br>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            </div><div class="table_heading">
                <h6>Fantasy Rankings</h6>
            </div>
            <div class="table_body">
                <? include("include/current_standing.php"); ?>
            </div>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <div class="table_heading">
            <h6>1st Half Schedule</h6>
            </div>
            <div class="table_body">
                <? include("include/races.php"); ?>
            </div>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            </div>
            <div id="right_column">
            <div class="table_heading">
                <h5><? echo $_SESSION[first_name]; ?>, Your Information</h5> 
            </div>
            <div class="table_body">
                <p>This is a work in progress</p>
            </div>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <div class="table_heading">
                <h5>Fantasy League News</h5> 
                <p>Last Updated: <? include("include/last_update.php"); ?></p>
            </div>
            <div class="table_body">
                <? include("include/display_comments.php"); ?>
            </div>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <div class="table_heading">
                <h5>Nascar News</h5> 
                <p>Click on a headline below to read the news.</p>
            </div>
            <div class="table_body">
                <div id="rss_feed"><p><? include("include/nascar_rss.php"); ?></p></div>
            </div>
        </div>
    </div><!--contentarea ended-->
<div id="footer">
    <div class="table_body">
        <p align="center">This page was designed by <a href="mailto:me@andybourdeau.com">Andy Bourdeau</a>.</p>
    </div>
</div>
</div><!--End Mainwrap-->    
</body>
</html>

This is culprit page

#4 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 01 March 2006 - 02:19 AM

The weirdest thing is that it is the second $_SESSION[first_name] that is showing the wrong name, then on refresh they both show the same name, but it is the wrong one.

I am confused on that!!

Help please!

#5 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 01 March 2006 - 02:49 AM

I think I know why this is doing it, in the second include, I am calling information from the same table and it includes $first_name. This is overwriting that variable. Is there anything I can do to get around this?

#6 komquat

komquat
  • Members
  • PipPipPip
  • Advanced Member
  • 130 posts
  • LocationHoughton, MI

Posted 01 March 2006 - 03:34 AM

I figured this one out as well.

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users