vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB5 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=263)
-   -   How to access vBulletin session info from other PHP applications on the same domain? (https://vborg.vbsupport.ru/showthread.php?t=327448)

vbSuperfan 08-08-2019 09:07 PM

How to access vBulletin session info from other PHP applications on the same domain?
 
I coding a small, simple light-weight PHP application (that is, I would like to avoid having to make it a full fledged "product"/plugin for vBulletin 5 Connect at this point) which must access the userid (and subsequently, username and usertitle) of the currently logged-in user in the vBulletin 5 Connect instance that is running on the same domain (that is, my PHP app will have access to the cookies of this vBulletin instance too).

My question is, what would be the simplest and most efficient way to get hold of this currently-logged-in-user-in-vBulletin information from this stand-alone PHP application of mine?

I'm guessing that the vBulletin user-sessions are not written to the database, but rather only using some kind of "memory only" PHP session kind of thing, which in turn would prevent me from using a database-only solution where all the above-mentioned information could be resolved directly from the vBulletin database by my application (based on initially looking up the session ID found in the vBulletin cookies etc), right?

Is there any good summarized info available for vBulletin 5 Connect for this kind of "Single Sign-On" functionality that anyone here knows of?

During my googling, I only managed to find similar info applying to vBulletin 3 (e.g. here), which I've heard has a very different user session handling than vBulletin 5 Connect though?

Any hints of any kind would be highly appreciated!

delicjous 08-09-2019 02:00 AM

That could be help and is the only one I know:
https://forum.vbulletin.com/blogs/da...n-your-website

vbSuperfan 08-09-2019 06:37 PM

Thanks for your reply!

I've seen that article when googling this, but as far as I can see, you must authenticate with a username and password before you can use any API:s at all like that, which would defeat the purpose of this method entirely for what I'm looking for (which could be described as the "reverse" of what that article is about), or am I misunderstanding something here?

This "autoloader.php" only provides access to the vB5 API, right?

Where can I find a good documentation for the vB5 API by the way, anyone knows?

shka 08-09-2019 09:50 PM

Good? I don't know. But there is http://vb5support.com/resources/api/

ART 08-22-2020 11:52 AM

Quote:

Originally Posted by vbSuperfan (Post 2600171)
I coding a small, simple light-weight PHP application (that is, I would like to avoid having to make it a full fledged "product"/plugin for vBulletin 5 Connect at this point) which must access the userid (and subsequently, username and usertitle) of the currently logged-in user in the vBulletin 5 Connect instance that is running on the same domain (that is, my PHP app will have access to the cookies of this vBulletin instance too).

My question is, what would be the simplest and most efficient way to get hold of this currently-logged-in-user-in-vBulletin information from this stand-alone PHP application of mine?
!


This is working for me (vb562 using vb API) look below. When calling the API the currently logged in user session also gets updated :) The sessions are stored in the database (prefix_session)

PHP Code:

// Path to your vBulletin installation
$vbpath 'xxxxxx';

define('CSRF_PROTECTION'false);
require_once(
$vbpath '/includes/vb5/autoloader.php');
vB5_Autoloader::register($vbpath);
vB5_Frontend_Application::init('config.php');

$userid vB::getCurrentSession()->get('userid'); 
$user_info vB_User::fetchUserinfo($userid0falsefalse); 

Now You could grab the usertitle from $user_info array
$user_info['usertitle']


All times are GMT. The time now is 12:30 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01273 seconds
  • Memory Usage 1,731KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete