Is there a way to pass a PHP value to JavaScript?
You're looking for drupal_add_js(). You can use it to pass data from PHP to JavaScript. Something like the following should suffice:

/**
 * Implementation of hook_init().
 */
function modulename_init() {
  if (!user_is_logged_in()) {
    drupal_add_js(array(
      'modulename' =&gt; array(
        'path' =&gt; $logged_out_path
      )
    ), 'setting');
  }
}


Note that I am calling this from within an implementation of hook_init(), but really you can do this anywhere, be it from a module or a theme. Also note that I have provided a sufficient namespace for the value to live (i.e. within 'modulename' => 'path'). This will make it clear from JavaScript's point of view exactly who owns the variable (i.e. which module it came from), but more importantly will help to prevent collisions with settings in other modules.

From JavaScript you can access the value of $logged_out_path like this:

var path = Drupal.settings.modulename.path;