Cookie Login data (4 posts)

  1. laqrhead
    Posted 6 years ago #

    I have a program running independent of wordpress, but I am setting it up to use the same user data. I'd like to use the wordpress admin for logging in and updating, but the URL's from my software aren't compatible with the wordpress permalinks so I'd like to keep it separate. I'd would like to check and see if a user is logged in and get their user_ID but I can't seem to find how that's stored in the wordpress cookie. The codex seems to only apply to versions <2.5, can anybody provide some insight in how to check if a user is logged in and fetch their user_ID outside of wordpress?

  2. laqrhead
    Posted 6 years ago #

    Ok, so I think I've found the cookie name:


    where HASH is there seems to be a site specific hash. Anybody know what it is, or how I can get it outside wordpress? For the one site I can just copy it, but it won't work on other sites.

    The values go like this I think:


    What is the middle value for?

    Anyways, I think I might be able to get by on this, but if anyone can provide more clues, I'd appreciate it.

  3. laqrhead
    Posted 6 years ago #

    Ok, so I can get it from here.

    You can set the cookie name in the wp-config.php file by adding:

    define('LOGGED_IN_COOKIE', 'my_cookie_name');

    The default is defined in wp-settings.php on line 392 as:

    define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);

    So now I'll always know what the cookie name is, so I can extract the username from the cookie value. Something like this should do the trick assuming that you have established your DB connection.

    $sql="SELECT ID FROM wp_users WHERE user_login LIKE '$user_login'";

    If you have a better way, let me know.

  4. Voogah
    Posted 6 years ago #


    Did you ever get this to work!

    I am trying to do the same thing!

    I have been successful acquiring the $user_id through wp globals but it only works with IE not Sarfari or Firefox.

    So I then tried using the cookies but I have gotten the same results.

    If you got this to work correctly in all browsers I would sure love some help!


Topic Closed

This topic has been closed to new replies.

About this Topic