in php i would do
if (isset($_COOKIE[\'user\']) && $_COOKIE[\'user\'] == $valueFromDb)
echo \'logged\';
But in javascript how can
When you want to know if user is logged on a page to do some type of special action, I usually use a hidden input with a special name that is checked on js. If the user is logged you put that on a master page or something like that and then in js check if it exist to know if the user is logged.
Something like: