Basically all you are doing with what you're showing us is setting the value of onLogin to the return of CheckLogin.
I whipped this up for you ...
<?php
session_start();
class foo {
var $onLogin = "";
var $sid = "";
function foo(){
return;
}
function initialize($sid){
$this->sid = $sid;
$_SESSION['sid'] = $this->sid;
}
}
function checkLogin($uname, $pwd) {
if($uname == 'Foo' && $pwd == 'bAr')
return session_id();
else
return false;
}
$class = new foo;
$class->onLogin = checkLogin('Foo', 'bAr');
if(!empty($class->onLogin))
$class->initialize($class->onLogin);
else
die('Bad credentials');
?>
The only thing it does is check a static username and password and sets a session variable for later access to verify the user has logged in before. It may not be the best example, but it works ... proving that what you, in a round about way, asked is possible.