Jump to content


Photo

session variables changes


  • Please log in to reply
3 replies to this topic

#1 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 06:06 PM

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

site:
http://207.5.19.133/sbqa

when logging in i set:

<?php
include $_SERVER['DOCUMENT_ROOT'].
        '/sbqa/layout2.php';
switch($_REQUEST['req']){ 
   
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'];

i include session permissions which include:

<?php
session_start();
session_name('SBQA');
header("Cache-control: private"); // Fix for IE

the problem is that when i go to the page:

http://207.5.19.133/...svp&event_id=43

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
  echo '- Welcome '.$_SESSION[first_name].'.

what gives??

#2 Wintergreen

Wintergreen
  • Members
  • PipPipPip
  • Advanced Member
  • 107 posts

Posted 15 September 2006 - 06:10 PM

You need session_start() at the top of each page

#3 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 06:13 PM

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

#4 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 10:01 PM

the problem stopped when i changed this bit of 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());
	 if(!$sql){
         echo 'Error getting determining event host: '.
              mysql_error();
      } else {
				while($row = mysql_fetch_array($sql)){
				stripslashes(extract($row));
					$event_host = $first_name.' '.$last_name;
			}		
		}

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users