Question: there is a way to check wordpress cookie **wordpress\_logged\_in** using jquery?

I'm using cloudflare full caching, so there is no way to check if user is logged or not than this cookie, I tried to read it using jquery but seems protected and not visible, I can access it only using PHP.

Here is how I can read it right now :

```
$logged_in = 'no'; 
if (count($_COOKIE)) {
    foreach ($_COOKIE as $key => $val) {
        if (preg_match("/wordpress_logged_in/i", $key)) {
            $logged_in = 'yes';
        }       
    }
}

```

Maybe there is a possiblity to check it simply by jquery, but I didn't find how.

Thanks for helping

Answer: 
If you only want to know if a user is logged in you can check if the body element has class 'logged-in' i.e.

```
jQuery( 'body' ).hasClass( 'logged-in' )

```

WordPress adds this class to the body element if a user is logged in.
Similar topic [here](https://wordpress.stackexchange.com/questions/69814/check-if-user-is-logged-in-using-jquery)

This solution will work for you. Or you can add action on [login action](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_login) and create js var for your file using `wp_localize_script()`.