This is a working script (tested on VB 5.0.1) that will create a random user and then log them in using their ID. If you already know a users ID then you can just log them in using the log_user_in function.
PHP Code:
<?php
chdir("forum/core/"); // change to your core folder location require_once("global.php");
// create random user $userid = create_random_user();
// log them in log_user_in($userid);
It's a script in its simplest of states. The usernames password is hardcoded but assuming you know what's going on in the above snippet, you'll be fine adding this yourself.