Jump to content

Archived

This topic is now archived and is closed to further replies.

komquat

Session info changes on Refresh

Recommended Posts

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

Share this post


Link to post
Share on other sites
Odd...unless, you haven't registered the session variables. :-)

Any chance you can paste some code?

Share this post


Link to post
Share on other sites
[code]
<?
//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;
[/code]

This is where I login and register variables

[code]
<?
//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>
[/code]

This is culprit page

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.