Drupal on custom page?
If the PHP file is in the same directory where cron.php, and index.php files from Drupal installation are, then you can use the following code.

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 

if (user_is_logged_in()) {
  //...
}


If the PHP file is in another directory, then you should use the following code.

/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', 'the directory containing the includes directory from Drupal');
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 

if (user_is_logged_in()) {
  //...
}