MyBB Community Forums

Full Version: Using mybb database a user account for site
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a site...python-gaming.com. We need the forum but we also need to make user accounts for the site. Can i just tap into the mysql database of the forum and use them. Basically using the mybb forum to make user accounts for the rest of the site. How would i do this?
From what I understand you have a custom website and also a MyBB forum. You want all registration to be handled on the forum. My answer is based on this assumption.

You want to set up header links to MyBB's registration page and connect to the database used by mybb. The session cookie doesn't contain the user_id (that'd be a security issue, don't save the userId in a separate cookie if that was one of the options you considered) so you will have to extract it from the sessions table via a query.

I would advise you not to use 2 database connections for the sake of sessions and keep your main website in the same database as mybb.

Your other options are:
* using php's native sessions and only acessing the mybb's database when a protected page is called and $_SESSION['user_id'] is not set. writing a mybb plugin to unset $_SESSION['user_id'] on logout and set it on login.
* setting a hashed cookie containing the user_id on mybb login and unsetting it on logout (not recommended, still an option)
* integrating your own registration with mybb and tweak the login system to redirect to your forum_login.php (which creates mybb session or displays your login page if not possible), long process but this is what I usually prefer

Let me know if you want me to explain any of the above.
that is exactly what i was looking for thanks.