Pulling user data from database without session_begin?

Discussion forum for MOD Writers regarding MOD Development.
Locked
User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Pulling user data from database without session_begin?

Post by MichaelTunnell » Thu Jul 02, 2009 11:52 am

I know this is a stupid question in general but there is a valid reason why I am asking this.

I use the Conduit toolbar service, if you don't know what that is then google will provide you the link (I'm not fully sure of advertising rules here).

Anyway, the toolbars support XML remote hosted menus and also support dynamically created php xml files which work just fine. It can pull information from the database and alter the xml just fine but when it comes to user data it fails badly.

I know you are suppose to use the session_begin function in order to get access to the userdata but when using the function inside the php-to-xml file it kills the session cookie anytime it is pulled into the toolbar. If you view the fire directly from the browser it works fine but once you refresh the toolbar to view it there the session is immediately deleted resulting in logging out anyone viewing the toolbar.

So I tried a few work arounds like trying to pulling data directly from the users table with and sql query ( yea I know, long shot)

here is the code I used for the direct pull

Code: Select all

$result = $db->sql_query("SELECT user_id, username
						FROM phpbb_users 
						LIMIT 1
						"
);
$fetch = $db->sql_fetchrow($result);
		$username 		= $fetch['username'];
		$user_id 		= $fetch['user_id'];
It connects to the table just fine but it never pulls anything other than Anonymous and 1 regardless if you are logged in or not.

So is there any way at all to get user data without the session_begin function?

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Pulling user data from database without session_begin?

Post by MichaelTunnell » Sun Jul 05, 2009 5:28 pm

I guess that is a sign that it isn't possible...well crap

User avatar
tumba25
Former Team Member
Posts: 4430
Joined: Wed Jun 06, 2007 6:42 am
Location: Kokkola, Finland.
Name: Jari Kanerva
Contact:

Re: Pulling user data from database without session_begin?

Post by tumba25 » Mon Jul 06, 2009 1:38 am

Using

Code: Select all

// Start session
$user->session_begin();
$auth->acl($user->data);
would really simplify it for you.
Need a mod/extension created/installed, other custom-coded solution or a server admin? https://tumba25.net

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Pulling user data from database without session_begin?

Post by MichaelTunnell » Mon Jul 06, 2009 1:55 am

thank you for replying but that doesn't help as like I said the problem is with

Code: Select all

$user->session_begin();
I am trying to use the phpbb3 userdata inside a Joomla module and anytime I try to use session_begin it fails.

User avatar
tumba25
Former Team Member
Posts: 4430
Joined: Wed Jun 06, 2007 6:42 am
Location: Kokkola, Finland.
Name: Jari Kanerva
Contact:

Re: Pulling user data from database without session_begin?

Post by tumba25 » Mon Jul 06, 2009 1:58 am

Maybe

Code: Select all

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

// Start session
$user->session_begin();
$auth->acl($user->data);
Would help. Your Jooma might have a $user->session_begin(); function to so you need to use the right one. You can unset their function IIRC.
Need a mod/extension created/installed, other custom-coded solution or a server admin? https://tumba25.net

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Pulling user data from database without session_begin?

Post by MichaelTunnell » Mon Jul 06, 2009 2:11 am

that may be the issue with two of the same functions conflicting...I'll look into that but would prefer an alternative way without session_begin.

User avatar
tumba25
Former Team Member
Posts: 4430
Joined: Wed Jun 06, 2007 6:42 am
Location: Kokkola, Finland.
Name: Jari Kanerva
Contact:

Re: Pulling user data from database without session_begin?

Post by tumba25 » Mon Jul 06, 2009 2:13 am

session_begin() sets the user array and fills it with needed info. What are you after? Only the user_id? Make your own session_begin() function?
Need a mod/extension created/installed, other custom-coded solution or a server admin? https://tumba25.net

User avatar
MichaelTunnell
Registered User
Posts: 211
Joined: Fri Apr 29, 2005 9:46 pm
Location: don't rush me
Name: Michael Tunnell
Contact:

Re: Pulling user data from database without session_begin?

Post by MichaelTunnell » Mon Jul 06, 2009 2:23 am

yes all I need is the user id...I could use that to do everything I want to do. I'm not quite sure on how to make my own session_begin to be honest

Edit: lol I just realized a mistake of mine...I was trying to get the session info from a different domain that created the cookie...

is there any way of doing that?

miguel_hughes
Registered User
Posts: 3
Joined: Wed Apr 08, 2015 4:33 pm

Re: Pulling user data from database without session_begin?

Post by miguel_hughes » Wed Apr 08, 2015 4:37 pm

Hey, I just wanted to post I found a workaround for this. Not sure if it works on all environments but it worked for me at least.
Instead of:

Code: Select all

$user->session_begin();
$auth->acl($user->data);
you can do

Code: Select all

$user->data['user_id'] = ANONYMOUS;
$auth->acl($user->data);
After this, other calls to $user and $auth seem to work, without needing to use headers or cookies

Locked

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