phpbb login check on custom pages

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
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

phpbb login check on custom pages

Post by Bomas »

I'm making a script for somebody and he wants a login, but when you log in to the site, you must also be logged in on the phpbb-forum.

I've been tying to make a script for days, but it doesn't work. Does anybody know any script to check wether you're online or not.

people told me to use this:

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);
//
// End session management
//
if($userdata['session_logged_in']){
/*
myscript running here
*/
}else{
die("Not logged in stuff");
}
but that only works on phpbb-pages itself, and not on my costum pages.

all help is welkom
thx
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

I haven't worked much with phpbb yet, but it sounds to me like you're just missing something. If you include all of the login code into any other page, it should work.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

make sure you're including the page with session info.

do a search for session_start() and just include that file.

the other alternative would be to set the phpBB cookie and just use that...or set another cookie for your other site stuff and use that.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

check out this viewtopic.php?t=27589 as it has an example on how to do it.
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

When in doubt, go to the source... http://www.phpbb.com/kb/article.php?article_id=143

Sphen001
User avatar
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

Post by Bomas »

Burrito wrote:make sure you're including the page with session info.

do a search for session_start() and just include that file.

the other alternative would be to set the phpBB cookie and just use that...or set another cookie for your other site stuff and use that.
I did, and it was located in the page: sessions.php, which is included in the page common.php. so it should run the page. The weird thing is, it doesn't isplay anything, it just keep running the rest of the script.
Sphen001 wrote:When in doubt, go to the source... http://www.phpbb.com/kb/article.php?article_id=143

Sphen001
that's the site i got the code from. but that doesn't work.

i've used the code u guys posted on the other topic, but that doesn't work either. It says session_logged_in = 0

i still don't get it
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Are you sure you are on the right domain. If you're forum domain is "forum.somesite.com" but your custom page on domain "somesite.com" you may not be accessing the right cookie. Thus you're not logged in. It can even be as subtle as "www.somesite.com" and "somesite.com".

Eh, you probably already thought of this...

Hope this helps
User avatar
Bomas
Forum Newbie
Posts: 24
Joined: Sun Oct 17, 2004 2:41 am
Location: Heverlee, Belgium

Post by Bomas »

i checked. the forum is located in the map ./forum/
and the session_start() is located in the map ./forum/includes, but that's the standard dir for phpbb

i haven't got a single clue of where the problem is located
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post by Sphen001 »

Well, where is your page in relation to the forum? If it isn't already, try putting your file in the root phpBB folder and see if that works.

Sphen001
Post Reply