RE: [PHP] Session not Registering
| From: | David Russell | Date: | Thu, 21 Nov 2002 12:45:05 +0000 |
| Subject: | RE: [PHP] Session not Registering | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125407@lists.php.net to get a copy of this message | ||
I assume that you do have a sesion_start() on the second (Target) page
It needs to be present on each page using your session.
David Russell
IT Support Manager
Barloworld Optimus (Pty) Ltd
Tel: +2711 444-7250
Fax: +2711 444-7256
e-mail: DavidR@BarloworldOptimus.com
web: www.BarloworldOptimus.com
-----Original Message-----
From: Stephen [mailto:webmaster@melchior.us]
Sent: 21 November 2002 02:43 PM
To: Ernest E Vogelsinger
Cc: PHP List
Subject: Re: [PHP] Session not Registering
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/
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Attachment: [application/x-pkcs7-signature] smime.p7s
Attachment: [application/x-pkcs7-signature] smime.p7s