WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to tell if a user is logged into Wordpress from looking at the cookies which are set on a site? If not, how could I add hooks to the login success and logout actions and set my own cookies?

share|improve this question
It would help to actually know those reasons. People might not agree with them, but such things are relevant technically. – Rarst Oct 9 '11 at 20:48
Downvotes are a hint that there are issues with a question as community sees it. You have my downvote now, since you stressed your attitude instead of fixing it. – Rarst Oct 10 '11 at 9:21
Wouldn't be a downvote (from my side), if you'd have taken the time to illustrate your needs instead saying: "I have my reasons and I don't care if you agree with them". This doesn't help any further readers, which is the purpose of this Q/A format. If you'd explain the why, later readers might get better insights whether your problem is related to their own or not. Btw: The attitude is more than just harsh and really not appreciated. – kaiser Oct 10 '11 at 10:18
@Rarst - you're right. I've reworded the question. My apologies. – cwd Dec 7 '11 at 18:20
@kaiser - you're right as well. I think I was frustrated by not being able to get Wordpress to work and should have spent more time on the question. I'm sorry and I've redone the question. – cwd Dec 7 '11 at 18:22
up vote 1 down vote accepted

You could use Javascript

<script type="text/javascript">
function getCookie(c_name)
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
  if (x==c_name)
    return unescape(y);

var logged_in=getCookie("wordpress_logged_in_[HASH]");
  if (logged_in!=null && logged_in!="")
  alert("You are logged in!");
   alert("You are logged out!");

NOTE: Wordpress logged in cookie info can be found here. You'll need to figure out what your hash is and possibly use regex for the hash. (this is untested but should work)

JS cookie source

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.