Using library:
Take a look at functions_login.php
I think I'm gonna write up a How-To for this
Manual:
This is a FAQ and has been answered dozens of times for vB 3.0.x already
"Being logged in" just means that you have the appropriate cookies set.
Namely
bbuserid and
bbpassword (bb is the default cookie prefix, so the cookies might be different if you use another prefix).
bbuserid should be obvious.
bbpassword is md5(md5(md5('plaintextpassword'). $salt) . 'LicenseNo');
The value of column password in table user is md5(md5('plaintextpassword') . $salt)