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

Discussion forum for MOD Writers regarding MOD Development.
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 »

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
Former Team Member
Posts: 22061
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

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

Post by RMcGirr83 »

root path is probably wrong.
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then you can support me by buying a beer 🍺
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 »

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 »

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

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

Post by AmigoJack »

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 problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28

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