Well the short answer is you can'tshouldn't easily, it raises all sorts of questions regarding the security model!
However there may be alternatives. You could for instance write an extension for EE that exposes an ACTion (as Derek said), or more simply just write a template, and then get your information through AJAX/curl from your other external page.
for instance suppose you had a template living at API/getUserEmail
, on that template you could do :
<?php
//is the AJAX request from the known source?
//here you can add code to ensure its just YOUR external site getting to this api
if ( $legitRequest ) {
//is the user logged in
$memberId = ee()->session->userdata('member_id');
if ( $memberId != 0 ) {
return json_encode(array('success' => ee()->session->userdata('email');));
} else {
return json_encode(array('error' => 'no user logged in'));
}
} else {
return json_encode(array('error' => 'permission denied'));
}
?>
Also, to get the ajax return with curl there's an example in the answer to this question : https://stackoverflow.com/questions/3928228/php-and-curl-get-ajax-data
Another alternative is to query the database directly, though you can't check if the user is logged in easily via a striaght database call.
If you wanted to go down the "instansiate the entire application" route check out the code in index.php (on the EE site) and try to replicate this bootstrap in your code, this could instansiate the EE object if you get it right, but that is a complicated affair!