Jump to content


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


session variables changes

Recommended Posts

my session variables arent staying set and i need some guidance as to where my problem lies.


when logging in i set:

case "validate":
//ensure they are not already logged in//
if($_SESSION['login'] != TRUE){

$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
    $validate = mysql_query("SELECT * FROM users
                          WHERE username='$username'
                          AND password = md5('$password')
                          AND verified='1'  AND disabled='0'
                          ") or die (mysql_error());
  if(mysql_num_rows($validate) == 1){
      while($row = mysql_fetch_assoc($validate)){
        $_SESSION['login'] = true;
        $_SESSION['userid'] = $row['id'];
        $_SESSION['first_name'] = $row['first_name'];
        $_SESSION['last_name']  = $row['last_name'];
        $_SESSION['email_address'] = $row['email_address'];[/code]

i include session permissions which include:

header("Cache-control: private"); // Fix for IE

the problem is that when i go to the page:

the NAME in the login box changes from my name (as was set in the session earlier)
to data from the event query.....

is shouldnt because the code for that box is
[code]  echo '- Welcome '.$_SESSION[first_name].'.[/code]

what gives??

Share this post

Link to post
Share on other sites
it is, my layout file includes variables and session includes that apply for every page that is shown.... so if it has the layout it ran through the sessionstart()  additionally i event added that to the top of the layout file so it would be run twice to no avail.....  still happens...

Share this post

Link to post
Share on other sites
the problem stopped when i changed this bit of code

[code] //determien the event hosts name
$sql = mysql_query("SELECT first_name, last_name FROM users WHERE
id ='$event_host'")
//id ='15'")//
or die (mysql_error());
         echo 'Error getting determining event host: '.
      } else {
while($row = mysql_fetch_array($sql)){
$event_host = $first_name.' '.$last_name;
} [/code]

it was originally set to a static host (id=15) but then i changed it so that it will show the name of the person who posted the event..... the problem is WHY is this piece of code changing the value of a session variable??

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.