[Solved] Guests merged into a single guest session

Get help with installation and running phpBB 3.3.x here. Please do not post bug reports, feature requests, or extension related questions here.
Post Reply
User avatar
[Dimetrodon]
Registered User
Posts: 435
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era
Contact:

[Solved] Guests merged into a single guest session

Post by [Dimetrodon] »

More of a minor annoyance here, but is there a way to not base Guest user sessions on IP? I'm using a reverse proxy tunnel (NOT cloudflare) for my site that ends up changing all IP addresses to localhost. This is not a problem, but has the strange effect of merging all guest sessions into one. No matter how many guests are online, it all comes up as "one guest."

Is there a way for me to change that? This doesn't effect logged in users, only guests.

Thanks.
Last edited by [Dimetrodon] on Fri Dec 23, 2022 5:11 pm, edited 1 time in total.
User avatar
Noxwizard
Support Team Leader
Support Team Leader
Posts: 10550
Joined: Mon Jun 27, 2005 8:41 pm
Location: Texas, USA
Name: Patrick Webster
Contact:

Re: Guests merged into a single guest session

Post by Noxwizard »

If you are behind a reverse proxy and it is correctly forwarding the IP via Forwarded-For, you can use an extension like this to restore users' IPs: viewtopic.php?t=2469351

Please note that the extension is still in development and has not gone through validation.
[Support Template] - [Read Before Posting] - [phpBB Knowledge Base]
Do not contact me for private support, please share the question in our forums.
User avatar
[Dimetrodon]
Registered User
Posts: 435
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era
Contact:

Re: Guests merged into a single guest session

Post by [Dimetrodon] »

Thanks again, I will check it out.
Avatar by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
When seeking support, please consider filling out the Support Request Template. It makes it easier for anyone trying to help.

An attempt at an alternative phpBB3 Refugees site: https://phpbbforever.com/index.php
User avatar
[Dimetrodon]
Registered User
Posts: 435
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era
Contact:

Re: Guests merged into a single guest session

Post by [Dimetrodon] »

Solved.

Unfortunately, the service I'm using does not use X-forwarded for. I thought all guests were merged into a single session but that wasn't true. All guests had their own session but phpBB counts number of guest IP addresses, as opposed to guest sessions open. So thankfully, not all guests were using the same session and it was only a cosmetic issue.

I went into functions.php and replaced session_ip with session_id under the "Get number of online guests" section. The edited code I'm now using is:

Code: Select all

	// Get number of online guests

	if ($db->get_sql_layer() === 'sqlite3')
	{
		$sql = 'SELECT COUNT(session_id) as num_guests
			FROM (
				SELECT DISTINCT s.session_id
				FROM ' . SESSIONS_TABLE . ' s
				WHERE s.session_user_id = ' . ANONYMOUS . '
					AND s.session_time >= ' . ($time - ((int) ($time % 60))) .
				$reading_sql .
			')';
	}
	else
	{
		$sql = 'SELECT COUNT(DISTINCT s.session_id) as num_guests
			FROM ' . SESSIONS_TABLE . ' s
			WHERE s.session_user_id = ' . ANONYMOUS . '
				AND s.session_time >= ' . ($time - ((int) ($time % 60))) .
			$reading_sql;
	}
	$result = $db->sql_query($sql);
	$guests_online = (int) $db->sql_fetchfield('num_guests');
	$db->sql_freeresult($result);

	return $guests_online;
}
And I went into viewonline.php and made similar changes. Replacing session_ip with session_id .
Avatar by someone named AdmiralRA on Reddit. (No, I don't have a Reddit account)
When seeking support, please consider filling out the Support Request Template. It makes it easier for anyone trying to help.

An attempt at an alternative phpBB3 Refugees site: https://phpbbforever.com/index.php
Post Reply

Return to “[3.3.x] Support Forum”