PhpBB's external login script thinks user is anonymous even when logged into forums

Discussion forum for MOD Writers regarding MOD Development.
Locked
TurdPile
Registered User
Posts: 5
Joined: Thu Nov 12, 2015 9:40 pm
Name: Chris

PhpBB's external login script thinks user is anonymous even when logged into forums

Post by TurdPile » Fri Nov 13, 2015 1:21 pm

Support Request Template
What version of phpBB are you using? phpBB 3.0.12
Do you have any MODs installed? Yes
Do you have any extensions installed? No
What styles do you currently have installed? prosilver
What language(s) is your board currently using? English
Which database type/version are you using? MySQL 5
What is your level of experience? Experienced in PHP, not PhpBB
What actions did you take (updating your board; installing a MOD, style or extension; etc.) prior to this problem becoming noticeable? As with most coding issues, lots of debugging and tweaking code.. but not PhpBB's
Please describe your problem.
I am utilizing PhpBB's ability to authenticate login on external pages outside of the forums. However, there is an intermittent issue (intermittent as in it comes and goes randomly to only a subset of users) where, even though the user logs into the forums fine, they are considered as a guest (eg Anonymous) via the external script that checks if they are logged in. I have used the standard script that everyone seems to be using, including the PhpBB help pages (see: How to create a custom page) which makes me think that this is a PhpBB issue.

Regardless, could use some guidance as to why this occurs.

Attached script:

Code: Select all

	define('IN_PHPBB', true);
	
	$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../phpbb/';
	$phpEx = substr(strrchr(__FILE__, '.'), 1);
	
	include($phpbb_root_path . 'common.' . $phpEx);

	// Start session management
	$user->session_begin();
	var_dump($user->data['username']);
	
Just this simple code, with nothing else, is producing random "Anonymous" or (is_registered = false) values.
Thanks!
Last edited by TurdPile on Sat Nov 14, 2015 2:44 pm, edited 3 times in total.

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 20934
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: External PhpBB script thinks user is anonymous even when logged into forums

Post by RMcGirr83 » Fri Nov 13, 2015 2:43 pm

root path is probably wrong.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

TurdPile
Registered User
Posts: 5
Joined: Thu Nov 12, 2015 9:40 pm
Name: Chris

Re: External PhpBB script thinks user is anonymous even when logged into forums

Post by TurdPile » Fri Nov 13, 2015 2:56 pm

I'm pretty certain if that was the case $user would be undefined. Also if this was the case, the problem wouldn't be intermittent.

TurdPile
Registered User
Posts: 5
Joined: Thu Nov 12, 2015 9:40 pm
Name: Chris

Re: PhpBB's external login script thinks user is anonymous even when logged into forums

Post by TurdPile » Fri Nov 20, 2015 1:16 am

Anything?

User avatar
AmigoJack
Registered User
Posts: 5334
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: PhpBB's external login script thinks user is anonymous even when logged into forums

Post by AmigoJack » Fri Nov 20, 2015 10:22 am

TurdPile wrote:even though the user logs into the forums fine, they are considered as a guest (eg Anonymous) via the external script that checks if they are logged in
The SID is important - it must either be passed directly (via GET or POST parameter) or indirectly (via cookie). I suspect those handful of users turn off cookies and you're not using append_sid() to publish URIs to your custom script.
The worst thing about censorship is ███████████

Locked

Return to “[3.0.x] MOD Writers Discussion”

Who is online

Users browsing this forum: No registered users and 14 guests