UBB.Dev
Posted By: dannylin How to use w3t's user authentication? - 08/06/2001 4:39 PM
I'm browsing those scripts and found the following codes:



// Require the library
require ("main.inc.php");

// -----------------
// Get the user info
$Username = $w3t_myname;
$Password = $w3t_mypass;

$userob = new user;
$user = $userob -> authenticate("$Username","$Password","U_Username, U_Password, U_Groups, U_TimeOffset");


then can I simply use


if ($user['U_Username'])
{
echo "Welcome home, $user[U_Username] !";
}
else
echo "YOU'RE NOT LOGINED.";


to check the user's login state?

Is that right?
Posted By: Rick Re: How to use w3t's user authentication? - 08/07/2001 12:41 AM
Yep, that should work fine.
Posted By: dannylin Re: How to use w3t's user authentication? - 08/07/2001 2:05 AM
Rick, I've got a strange problem on this.

I'm having these codes: (in a different directory to w3t)

[:blue]
<html>
<head>
[:orange]
<?
// Require the library
require ("../forum/main.inc.php");
require ("../forum/languages/$lang[THIS_FILE]/wwwthreads.php");

// -----------------
// Get the user info
$Username = $w3t_myname;
$Password = $w3t_mypass;

$userob = new user;
$user = $userob -> authenticate("$Username","$Password","U_Username, U_Password, U_Groups, U_TimeOffset");

}
?>


<title>mediafront</title>
blah..blah..blah...

[:orange]
<?

if ($user['U_Username'])
{
echo "$lang[INTRO_SUB], $user[U_Username]";
}
else
{
echo "
<form method=POST action="$config[phpurl]/start_page.php">
<input type=HIDDEN name=Cat value="">
<font size=1>Your ID:</font>
<input type=text name = Loginname class="formboxes" size="8"><br>
<font size=1>Password:</font>
<input type=password name=Loginpass class="formboxes" size="8">
<input type=submit name=option value="Login" class="buttons">
<font size=1 color=#FF0000><a href=$config[phpurl]/newuser.php>Register Now!</a></font>
</form>
";
}
?>


blah..blah..
</body>
</html>


But the variable $user['U_Username'] seems not worked.
When I try to strip the above paragraph of codes to only:
[:orange]
echo "$lang[INTRO_SUB], $user[U_Username]";

I can see only [:orange]Welcome, on the screen.
But the same codes could be worked simply fine when this scripts was located in w3t's directory. What's the problem?

BTW, I use session for user authentication.
Posted By: Rick Re: How to use w3t's user authentication? - 08/07/2001 3:49 PM
I'm not sure. I don't know all the details on sessions if they work domain wide or if they are limited to certain directories. If they are limited to the directory they are created within then that is probably the reason as the session variables can't be accessed from a different directory.
Posted By: dannylin Re: How to use w3t's user authentication? - 08/07/2001 5:10 PM
I've try to do some more test on this issue and found this:

The require is using a absolute path to the server but not the web server. So when someone tried to write their own scripts and put them in the root of their web site, they should use require ('/www/forum/main.inc.php'); instead of using require ('/forum/main.inc.php'); .

And also if there were require commands located in main.inc.php, they should be all changed to absolute path too.

But I still can't find the problem on the session issue.
Maybe it's not a session problem but the absolute path and relative path problem (w3t is currently using a relative path on all of its configured path and it might worked fine if it was a absolute path I guess)
Posted By: Shalazar Re: How to use w3t's user authentication? - 08/08/2001 4:02 AM
You may want to consider adding an extra table to your database to store the session information in, so regardless of whatever page the user is visiting, you can query the table for the session information, and empty the table upon exit.
© UBB.Developers