Re: Session not Registering

From: Date: Thu, 21 Nov 2002 12:42:36 +0000
Subject: Re: Session not Registering
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-125405@lists.php.net to get a copy of this message
I didn't orginially put that there. I also made it echo out the session varaible on the first page where they login and it displayed correctly. It's just when you go to a new page. The line 38 is the part where it echos out. ----- Original Message ----- From: "Ernest E Vogelsinger" <ernest@vogelsinger.at> To: "Stephen" <webmaster@melchior.us> Cc: "PHP List" <php-general@lists.php.net> Sent: Thursday, November 21, 2002 3:26 AM Subject: Re: [PHP] Session not Registering > At 04:02 21.11.2002, Stephen said: > --------------------[snip]-------------------- > >I have a PHP script that logs someone in then takes them to another page > >indicating their online status. However, when I try echoing out the > >contents of the session variable, it says this: > > > > Notice: Undefined variable: _SESSION in c:\program files\apache > > group\apache\htdocs\checker\members\index.php on line 38 > > > >Here's the code that registers the variable, or is atleast supposed to: > > > > if ($dbconn) { > > $querystr = "SELECT user FROM users WHERE (user = '" . > > prepareData($_POST['user']) . "' and pass=PASSWORD('" . > > prepareData($_POST['pass']) . "'))"; > > $result = mysql_query($querystr,$dbconn); > > if ($result) { > > if ($frow = mysql_fetch_row($result)) { > > session_start(); > > session_register('user'); > > $_SESSION['user'] = $frow[0]; > > header("Location: index.php?" . SID); > > exit(); > > } > > else { > > $error = "Invalid username and password combo."; > > } > > } > > > >Here's where I echo it out: > > > > <div align="left" class="log"><font > > size="2">Logged in as <?php echo > > $_SESSION['user']; ?></font></div> > --------------------[snip]-------------------- > > What's line 38 - is it the line where you assign to it, or is it the line > with the echo? > > If it's the line with the assignment - duh, this should work IMHO > if it's the line with the echo - you got nothing from mysql and didn't > start the session. > > BTW - you shouldn't mix session_register() and accessing the $_SESSION > array. Definetely it's not needed. > > > -- > >O Ernest E. Vogelsinger > (\) ICQ #13394035 > ^ http://www.vogelsinger.at/ > >

« previous php.general (#125405) next »