bbPress

Simple, Fast, Elegant

bbPress support forums » Installation

Getting user session info on non forum page

(4 posts)
  • Started 2 months ago by irr1449
  • Latest reply from HowToGeek
  • This topic is not resolved
  1. I'm using WP/BBP as a site wide CMS. It's been really great so far thanks to the light-weightness of bbPress. I've really just had to hack the tables and change a little code to get the extra info in there that I want.

    The only issues I'm wondering about is how to get the user data on a non bbPress page... I need to see if the user is logged in, and then get their userId...

    Just to give you an example, I allow the user to save certain things, and I use the user id from the wp/bbpress users table. Can anyone suggest a light weight way to do this?

    Posted 2 months ago #
  2. I assume this is a non-WP page as well?

    You can check the bbpress session cookie and then use that to check the user against the database. You'd have to use the same logic that WP or BB uses (the latest bbpress changes this logic). You'll also need to make sure that the cookie domain is set correctly.

    I've actually had to do this recently myself... it's pretty simple and works well.

    Posted 2 months ago #
  3. I don't have the code infront of me right now, but is it just going to be something like

    $_SESSION['whatever']

    And then that would give me the userId which I could then query the users table with?

    Posted 2 months ago #
  4. You'll need to use the PHP functions to check the cookies... bbpress doesn't use sessions by default.

    Also, you wouldn't want to simply use the userid, because that would be insecure since anybody could hack a cookie with any username.

    bbPress and WP both store two cookies, the username and the encrypted hash of the password. You'll have to use those in combination to do a lookup to the database to make sure they both match. I'd advise taking a look through the bbpress source code... it's not terribly difficult to understand.

    The other thing you could do... you could create a plugin / hack for bbPress to assign a session parameter after a successful login, which you could then check for in your other code.

    Posted 2 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.