if user is logged in only
If you write down this piece of code outside any hook or function, it is normal that it loops because the user is always "not logged in".

However, if you've created your "page" through the admin menu system, as Parvind said, you can use Menu Access module or use that piece of code:

function hook_node_view($node, $view_mode) {
  if($node-&gt;nid == 'yournodeid" &amp;&amp; $view_mode == 'full') {
    if (!user_is_logged_in()) 
      drupal_goto('user/login');
  }
}


If you've created the node programmatically (hook_menu()), you can use access argument like this:

$items['testpage'] = array(
  'title' =&gt; 'Authenticated users',
  'page callback' =&gt; 'test_func',
  'description' =&gt; 'This page is accessible to authenticated users only',
  'access callback' =&gt; 'user_is_logged_in',
  'type' =&gt; MENU_CALLBACK,
);