Title: Cookie Login data
Last modified: August 19, 2016

---

# Cookie Login data

 *  [laqrhead](https://wordpress.org/support/users/laqrhead/)
 * (@laqrhead)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/cookie-data/)
 * 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?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [laqrhead](https://wordpress.org/support/users/laqrhead/)
 * (@laqrhead)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/cookie-data/#post-1142481)
 * Ok, so I think I’ve found the cookie name:
 * wordpress_logged_in_HASH
 * 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:
 * username|someNumber?|hashedPassword?
 * 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.
 *  Thread Starter [laqrhead](https://wordpress.org/support/users/laqrhead/)
 * (@laqrhead)
 * [16 years, 11 months ago](https://wordpress.org/support/topic/cookie-data/#post-1142503)
 * 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.
 *     ```
       $userArr=explode('|',$_COOKIE[my_cookie_name]);
       $user_login=$userArr[0];
   
       $sql="SELECT ID FROM wp_users WHERE user_login LIKE '$user_login'";
       $query=mysql_query($sql);
       $resultArray=mysql_fetch_array($query);
       $user_id=$resultArray[ID];
       ```
   
 * If you have a better way, let me know.
 *  [voogah](https://wordpress.org/support/users/voogah/)
 * (@voogah)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/cookie-data/#post-1142830)
 * laqrhead,
 * 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!
 * Thanks!
    Voogah

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Cookie Login data’ is closed to new replies.

## Tags

 * [cookies](https://wordpress.org/support/topic-tag/cookies/)
 * [login](https://wordpress.org/support/topic-tag/login/)
 * [users](https://wordpress.org/support/topic-tag/users/)

 * 3 replies
 * 2 participants
 * Last reply from: [voogah](https://wordpress.org/support/users/voogah/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/cookie-data/#post-1142830)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
