PDA

View Full Version : How to check if user is logged in, non-vb page?


sparknote_s
08-01-2005, 11:42 PM
I know how to program in PHP and interact with mysql so don't worry about that part. I just need to know what files to include() and what variables. Basically I want to do this:

//Check if user is logged in

//If logged in, get username in a variable

And that's pretty much it. It would also be nice if they are not logged in, display a small login box. But that is not necessary, I really need to know how to do the above.

Thanks in advance!

Adrian Schneider
08-02-2005, 01:12 AM
chdir('./path/to/global.php/'); //optional
include('./global.php');

if (!$bbuserinfo['userid'])
{
print_no_permisson();
}

else
{
$username = $bbuserinfo['username'];
}
chdir('./path/back/to/your/scripts'); //optional


You can still use the $bbuserinfo array to access user info. The chdir stuff is only necessary if vbulletin isn't in the same directory.

sparknote_s
08-02-2005, 04:30 AM
Whoa thanks! I had no idea it was so easy! You are SOOO COOL thanks!

Fallback
08-02-2005, 03:40 PM
does this add queries when this is run by each user?

Adrian Schneider
08-02-2005, 04:31 PM
Yes. I think I read 6 somewhere, but I just woke up, so who knows.

Fallback
08-02-2005, 04:42 PM
I can believe it. It quadrupled our server load. If there was a way to cache this or something it would be awesome.

leenster
06-11-2006, 08:45 PM
chdir('./path/to/global.php/'); //optional
include('./global.php');

if (!$bbuserinfo['userid'])
{
print_no_permisson();
}

else
{
$username = $bbuserinfo['username'];
}
chdir('./path/back/to/your/scripts'); //optional


You can still use the $bbuserinfo array to access user info. The chdir stuff is only necessary if vbulletin isn't in the same directory.

when i try this i get nothing, it seems like im not logged in but i am..

<?
chdir('../forums/'); //optional
include('global.php');

if (!$bbuserinfo['userid'])
{
echo "user id =".$bbuserinfo['userid']."</br>";
echo "username = ".$bbuserinfo['username'];
}

else
{
$username = $bbuserinfo['username'];
echo "user id =".$bbuserinfo['userid']."</br>";
echo "username = ".$bbuserinfo['username'];
}

?>


result is:

user id =
username =

Adrian Schneider
06-11-2006, 08:52 PM
That was for vB 3.0.x

Use $vbulletin->userinfo instead of $bbuseirnfo

egoldregion
06-15-2006, 01:04 AM
Thanks.