in php i would do
if (isset($_COOKIE[\'user\']) && $_COOKIE[\'user\'] == $valueFromDb) echo \'logged\';
But in javascript how can
You are mixing up server-side processing (php) with client side processing (javascript). On the client side this information does not exist unless the server has provided it in some framework-specific way.