Re: User Authentication
| From: | shaun | Date: | Tue, 18 Mar 2003 19:02:59 +0000 |
| Subject: | Re: User Authentication | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140167@lists.php.net to get a copy of this message | ||
i have changed the code to:
//register the session variables
$_SESSION['ses_name'] = mysql_result($result, 0, "User_Name");
$_SESSION['ses_pass'] = mysql_result($result, 0, "User_Password");
$_SESSION['ses_level'] = mysql_result($result, 0, "User_Type");
but if i try to log in again the session variables don't change, any ideas?
"Olinux" <olnx@yahoo.com> wrote in message
news:20030318182440.14979.qmail@web11804.mail.yahoo.com...
> use:
> $_SESSION['ses_name'] = 'something';
> $_SESSION['ses_pass'] = 'something';
> $_SESSION['ses_level'] = 'something';
>
> instead of:
> > session_register("ses_name");
> > session_register("ses_pass");
> > session_register("ses_level");
>
> All $_SESSION entries are automatically registered.
>
> See the following for more info
> http://us2.php.net/manual/en/security.registerglobals.php
> http://us2.php.net/manual/en/function.session-register.php
>
> olinux
>
> --- shaun <shaun@mania.plus.com> wrote:
> >
> > "Chris Shiflett" <shiflett@php.net> wrote in message
> >
> news:20030318162508.83387.qmail@web14305.mail.yahoo.com...
> > > --- shaun <shaun@mania.plus.com> wrote:
> > > > Using the following code I am able to
> > authenticate which type of user is
> > > > visiting my page, however if I try to log in
> > again with a different type
> > of
> > > > user the session variables still assume that the
> > original user was
> > logged
> > > > in, is there a way to reset the session
> > variables, I have tried
> > > > session_destroy() and session_unset() but
> > without success...
> > > >
> > > > <?php
> > > > require("dbconnect.php");
> > > >
> > > > // Assume user is not authenticated
> > > > $auth = false;
> > > >
> > > > // Formulate the query
> > > > $query = "SELECT * FROM WMS_User WHERE
> > > > User_Username = '$_POST[username]' AND
> > > > User_Password = '$_POST[password]'";
> > > >
> > > > // Execute the query and put results in $result
> > > > $result = mysql_query( $query )
> > > > or die ( 'Unable to execute query.' );
> > > >
> > > > // Get number of rows in $result.
> > > > $num = mysql_numrows( $result );
> > > >
> > > > if ( $num != 0 ) {
> > > >
> > > > // A matching row was found - the user is
> > authenticated.
> > > > $auth = true;
> > > >
> > > > //get the data for the session variables
> > > > $suser_name = mysql_result($result, 0,
> > "User_Name");
> > > > $suser_password = mysql_result($result, 0,
> > "User_Password");
> > > > $stype_level = mysql_result($result, 0,
> > "User_Type");
> > > >
> > > > $ses_name = $suser_name;
> > > > $ses_pass = $suser_password;
> > > > $ses_level = $stype_level;
> > > >
> > > > session_register("ses_name");
> > > > session_register("ses_pass");
> > > > session_register("ses_level");
> > >
> > > This is the moment where you lose your new session
> > data. You need to
> > register
> > > your session variables before you use them. At
> > this point, PHP retrieves
> > the
> > > session data that is saved for you, and you lose
> > all of the stuff you did
> > > above.
> > >
> > > Chris
> > >
> > > =====
> > > Become a better Web developer with the HTTP
> > Developer's Handbook
> > > http://httphandbook.org/
> >
> > sorry but you have lost me, surely the
> > session_register(); function is
> > storing what I have done above this point, if not
> > then how would I store the
> > new values instead?
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> http://platinum.yahoo.com