Interesting question. Here's how you do it in your PHP code:
define('QA_BASE_DIR', '/PATH/TO/Q2A/');
require_once QA_BASE_DIR.'qa-include/qa-base.php';
require_once QA_BASE_DIR.'qa-include/qa-app-users.php';
require_once QA_BASE_DIR.'qa-include/qa-db.php';
qa_base_db_connect(null);
echo qa_get_logged_in_userid().' '.qa_get_logged_in_handle().' '.qa_get_logged_in_email().' '.qa_get_logged_in_level();
Replace /PATH/TO/Q2A/ above with the full path to your Q2A directory (the directory that includes qa-config.php). The last line shows the kind of information you can extract about the logged in user. If no user is logged in, all of these functions (defined in qa-app-users.php) return null.