MyBB Community Forums

Full Version: MyBB Login Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I have decided to use MyBB on my site. I would like to integrate it with my existing site. I would like to do two things
  • I already have a user login system. I would like to migrate all my current users to the MyBB user system.
  • I would like to use MyBB's user login system through out my site. But I would like to avoid the overhead of using MyBB's entire login system, because that is doubling my page load time. Hence I want to redirect my user to MyBB's login system for completing the login process. After that, in my other pages, I would like to directy query the MyBB sessions table to get the user details (All that I need is Username, Name, Email, Status(Banned or not), Privilege Level(Admin/ Moderator/ Normal User/Awaiting Activation)).

Can anyone please tell me how to do this?

Thanks
Can anyone plz tell me how I can do this? Atleast tell me where I can find information on how to do this?

Thanks
I tried a Apache Benchmark test.

I benchmarked without using any login check, with phpbb's login system and mybb's login system.

Without Any Loign Check - appoximately 1.7 sec
With phpBB's login system - approximately 3.5 seconds
With MyBB's login system - approximately 4.7 seconds
Hmm....When integrated with my existing site, phpbb is faster. But when I benchmarked the homepage and a thread, MyBB is faster Smile
I generally wouldn't benchmark pages on login times. The number of people logging in is going to be very small compared to the number of pages being viewed.

I would've suggested just using the MyBB login system, supplying the "url" parameter to member.php, which will redirect you back to a specified page, but it seems like you've got something already Toungue
For getting sessions, the main thing is including class_session.php and initializing the session.
The problem is that I already have a site with several sections that require my users to login. And for those sections I had created my own database abstraction library, and it is not possible now to use MyBB's database class. Hence I have to include both my files and MyBB's files, which was making my pages very slow. All I needed to know was whether the user is
  • logged in
  • an admin/moderator
  • is banned or not.

I created a custom global.php and removed all those lines of codes that were irrelevant for me (like Error Handling object, Template Object, Plugins Object). And replaced conditional statements with hardcoded statements(for example I will be using MySQLi, so why check for other databases). By doing this I could double the speed.

It would've been great if MyBB provided a bare essential Login System for the external site integration. I hope you will seriously consider this. This is something that most Forum Softwares lack at the moment.

ZiNgA BuRgA Wrote:I generally wouldn't benchmark pages on login times. The number of people logging in is going to be very small compared to the number of pages being viewed.
By MyBB's login system, I meant including global.php and checking for $mybb->user
By phpBB's login system, I meant including the common.php and config.php files and checking the $user object.
global.php loads quite a few things actually, that you really don't need.

I'd just make a simplified class_session, for example:
- connect to relevant DB - use inc/config.php if necessary
- load the usergroups datacache (I suggest storing the datacache in files to avoid a query)
- check the mybbuser cookie (if you're using cookie prefixes, you may need to load the settings to determine your cookie prefix)
- query the database to see if the cookie being sent over is a valid uid/loginkey pair
- check the usergroups cache to determine if the user is banned, admin etc

This should free you from a lot of processing MyBB does.
(2008-08-27, 06:39 AM)ZiNgA BuRgA Wrote: [ -> ]global.php loads quite a few things actually, that you really don't need.

I'd just make a simplified class_session, for example:
- connect to relevant DB - use inc/config.php if necessary
- load the usergroups datacache (I suggest storing the datacache in files to avoid a query)
- check the mybbuser cookie (if you're using cookie prefixes, you may need to load the settings to determine your cookie prefix)
- query the database to see if the cookie being sent over is a valid uid/loginkey pair
- check the usergroups cache to determine if the user is banned, admin etc

This should free you from a lot of processing MyBB does.

Thanks a lot Smile

I will surely follow your advice and try creating a custom class. And come back with more problems Big Grin