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.
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.
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