• My blog is on the /blog/ subdirectory of my web site. It all works great.

    I need the page at / on the site to be able to detect whether the user is logged in as a blog subscriber.

    The cookies for wordpress are all set in SITECOOKIEPATH to /blog/. When I check $_COOKIE in /, I can’t see the values.

    I tried doing a define of SITECOOKIEPATH in wp_config.php, but the define doesn’t work.

    What is the best way to find out if the user at the computer is logged into the wordpress blog from up the directory tree?

Viewing 4 replies - 1 through 4 (of 4 total)
  • I am making a big guess here that you are on the right path so take a look at https://umwblogs.org/wiki/index.php/Integrating_WPMu%2C_BuddyPress%2C_and_bbPress

    and how

    ‘COOKIE_DOMAIN’,’SITECOOKIEPATH’,’COOKIEPATH’, ‘COOKIEHASH’ and ‘WP_AUTH_COOKIE_VERSION’ were used.

    Also see Integrating_WordPress_with_Your_Website

    Thread Starter rexgoode

    (@rexgoode)

    Thanks, between your two link suggestions, I got it working.

    In addition to SITECOOKIEPATH, I needed to also define COOKIEPATH and COOKIE_DOMAIN in my wp-config.php. I also realized that the defines must come before wp-settings.php is required.

    Now, when users are on my site and not logged into my WordPress blog, a nice icon invites them to subscribe or log in to it.

    Still one problem left. With these set this way, I can log in and log out of my wordpress installation, but I can only do it as one user. If I try to log in as a different user, it won’t log me in.

    Thread Starter rexgoode

    (@rexgoode)

    So, I woke up this morning and tried to log in. No dice. It just kept going back to the log in form. I commented out the defines in wp-config.php and I could log in again. So, I’m kind of back to square one.

    So, here’s part of my wp-config.php. Some of the values have been changed to protect the innocent (me), but I believe I have the right values in my actual wp-config.php.

    define('ABSPATH', dirname(__FILE__).'/');
    //define( 'COOKIEHASH', '####my_hash_obtained_as_described_above####' );
    //define( 'COOKIE_DOMAIN', '.mydomain.org' );
    //define( 'SITECOOKIEPATH', '/' );
    //1\define( 'COOKIEPATH', '/' );
    require_once(ABSPATH.'wp-settings.php');

    I’m working off of my plan B right now, if anyone is interested.

    I made a plugin that sets a more global cookie when someone logs in and “unsets” it when they log out. Trouble is, I can’t detect when their real set of cookies expire. My root level pages can look for my cookie and act accordingly. I’d rather really know when the user is logged in or not.

    here’s a thread that might answer your question. you probably also need to put

    require_once('./blog/wp-blog-header.php');

    in whatever page in your site root that’s trying to access the login info.

    btw, a related problem arises when people try to display their blog at the root url but host the wp files in a subdirectory of the root. here’s an explanation of the problem, and the technique (basically what you just described above) for dealing with it.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Detecting Logged In’ is closed to new replies.