This is the entirety of the VB integration, placed at the very top in the header of my non-forums pages (which are all located in the root folder of my site). This inclusion, along with the little 3.5.1 hack I mentioned above, will properly update the 'session' table whenever someone visits a page outside of the forums:
PHP Code:
//Require backend:
chdir('forums/');
require_once('./global.php');
chdir('../');
Then I use
$vbulletin throughout the site, for the userid (if $vbulletin->userinfo['userid'] >= 1, visitor is a logged-in member), username, group id ... determining member/group restrictions, etc.
Oh and I don't define THIS_SCRIPT there, because I don't use any of vBulletin's templating or WOL... or anything else except the $vbulletin data. So.. your mileage may vary.