Log in

View Full Version : phpBB: Check session (logged in user?)



temp304
08-18-2007, 09:08 AM
Where is code to check session (logged in user?) in whole of phpBB code?

Can everyone show me? Thank you very much

djr33
08-18-2007, 10:43 AM
I don't know how phpBB works.
Just check the database and/or session variables and see if they verify with the database records.
http://php-mysq-tutorial.com will give you all of the commands needed.
However, to use this, you'll need to figure out how phpBB stores this. I'd suggest asking at a phpBB support forum, where they know this.

tech_support
08-18-2007, 11:15 AM
It could be $_SESSION['user'] but that's just a guess.

Mike007
08-29-2007, 06:33 PM
Ok man, i just found your post on google(don't you just love google?! :) lol) because i was trying to do the same thing as you and i was searching for answers. I found them myself several minutes later but i just thought i should help you, in case you still haven't figured it out (or anyone else for that matter).

So, the code for checking if a user is logged in or not is found in the sessions.php(phpbb/includes/sessions.php) file, there you will find several functions that deal with, well sessions. The function you'll want to look at is called "session_begin". Scroll to the end of that function and you'll see that there is an array called '$userdata', now you can check if a user is logged in or not just by checking the value of $userdata['session_logged_in']. There is also alot more useful information about the user in that array.

Another way would be to examin these 2 lines:

setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);
setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);

You can check the cookies to see if user is logged in or not too i believe.

In addition, you might find it useful to look at the login.php to help you log the user into your forum.

Hope that helped, good luck! :)