problem in fetching user id from phpbb2 session.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

problem in fetching user id from phpbb2 session.

Post by itsmani1 »

i am using phpbb2 and i want to fetch userid from session can any one help me in this regards. i have successfully checked wheather the user has logged in or not but i don't know which user has logged in?

Help Please.....

Abdul Mannan.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

where in the code are you adding this new code? I ask because $userdata, last I saw, had the information for you..
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Code: Select all

session_start();
	define('IN_PHPBB', true);
	$phpbb_root_path = '../phpBB2/';
	include($phpbb_root_path . 'extension.inc');
	include($phpbb_root_path . 'common.'.$phpEx);
	$userdata = session_pagestart($user_ip, PAGE_INDEX);
	init_userprefs($userdata);

if ($userdata['session_logged_in']) 
{
          echo "User has logged in.....";
}
now what happens when user is logged in it prints the string other wise it don't but i don't know what is the user id who has logged in?

Thanx.
Mannan.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:where in the code are you adding this new code? I ask because $userdata, last I saw, had the information for you..
how can i get info from user data ?
if I try

Code: Select all

if ($userdata['session_logged_in'])
it tells me wheather user has logged in or not? but it don't tell me which user has logged in?

Thanx.
Mannan.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have you looked at what data is inside the array? :roll:
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

feyd wrote:have you looked at what data is inside the array? :roll:
i tried but i did not found. the only thing i got i have told you, if you know plz tell me.

Thanx.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

Yeah its done :)

it can be done by :

$userdata['user_id']


Abdul Mannan.
Post Reply