PDA

View Full Version : User ID in VB


MajidOnline
10-06-2005, 12:32 PM
Hello,

I whould like get ID of the users logged in, in my program .

How I can do it ? the user ID write in session or cookie ?

Thank you,
Majid

Marco van Herwaarden
10-06-2005, 02:27 PM
You mean you want the userid of the user loading the page? Or of all online users?

MajidOnline
10-08-2005, 10:15 AM
You mean you want the userid of the user loading the page? Or of all online users?

I have written a program that the users can upload files .(I haven't programmed this program under the VB or forums program and it is something seperated).

Now I want to do sth that my user IDs would be saved in my database as they log in.

for instance When my forums system were PHPBB the user information was saved in a session that I could use it anywhere in my site.

moondragon13
12-26-2005, 06:51 AM
I am also looking for this information. I tried the following:


require_once($_SERVER['DOCUMENT_ROOT'] . "/forums/global.php");

// IF USER IS LOGGED IN
if ($bbuserinfo[userid])
{
// CODE TO EXECUTE IF USER IS LOGGED IN
echo 'logged in';
}
else
{
// CODE IF USER IS NOT LOGGED IN
echo 'not logged in';
}


You would think this would work. I just need to verify the user is logged in when they are on other pages outside the forum.

merk
12-26-2005, 08:23 AM
$vbulletin->userinfo['userid'] is the proper variable now days.

Though, requiring vbulletin's files may screw with the enviroment of your scripts.

Marco van Herwaarden
12-26-2005, 09:53 AM
Yes you should be using $vbulletin->userinfo for vB3.5.

Also please note that you will have problems if you include global.php like that. You should first chdir() to your forum homedirectory, then require global.php, and if needed chdir back.

merk
12-26-2005, 10:03 AM
Not anymore Marco, ever wonder why all the requires() use "DIR" now? :)

Define DIR as the forum's full path, and you can require it like that.

Marco van Herwaarden
12-26-2005, 11:48 AM
Hmm i guess it would work if you manually define DIR.

Normal global.php is the exception to the DIR rule, since it will set it to the current directory if not set yet.

merk
12-26-2005, 09:56 PM
Which is why you need to define it first, but at least you dont have to muck around with chdir anymore :)

Paul M
12-26-2005, 10:10 PM
Not anymore Marco, ever wonder why all the requires() use "DIR" now? :)

Define DIR as the forum's full path, and you can require it like that.Actually, if you look in the vb scripts, non of them use DIR to require global.php (because it's defined by init.php, which is called by global.php).

merk
12-27-2005, 12:59 AM
I dont see what the problem is. Defines cannot be overwritten.

If vbulletin is in /home/site/forum/ and your php script is in /home/site,


define('DIR', '/home/site/forum');
require_once('/home/site/forum/global.php');