First off, you are not passing the $loggedin variable to the second snippet, do this normally with a post or session variable.
Second, there is an easier way to check, these are straight out of Bob's guides.:
There are various methods. One easy method is to use this code:
if ($modx->user->get('username') == '(anonymous)') {
/* user is not logged in */
}
Here is the official method for seeing if the user is logged in
to the current context:
if ($modx->user->hasSessionContext($modx->context->get('key'))) {
/* user is logged in */
}
If you know the name of the current context (e.g., web),
you can use this method. The name of the context is required:
if $modx->user->isAuthenticated('web') {
/* user is logged in to web context */
}
that is if you need to roll your own authentication for some reason. ~ Otherwise, the login/register extra will do all of this for you.
*UPDATE***
Two pass variables from one snippet to another in the same resource you can set/get placeholders:
<?php
// snippet one
$modx->setPlaceholder('output','Place holder set!');
<?php
// snippet two
$myvar = $modx->getPlaceholder('output');
echo 'this is the value of "output": '.$myvar;