Bit of advice?
Next time, if you can avoid it, don't change the hard-code. :3 Instead, use the Plugin/Hook system that vBulletin created for us. This is because any changes you make directly to the file can and will be over-written upon a forum update.
The hook in question you should use is
register_signup.
For those wishing to do this to their forums, go to your AdminCP, "Add a New Plugin", choose 'register_signup' as the hook location (title it whatever you want).
You can use the same code Saurdo created above in that location:
PHP Code:
setcookie('register_referrer', $_SERVER['HTTP_REFERER'], 0, '/');
For the actual redirect, create another Plugin, and use the Hook Location
register_addmember_complete. In this hook, use the following code:
PHP Code:
if (!$vbulletin->GPC['coppauser'])
{
// CLEAN THE COOKIE DATA! Not particularly important here, but it's good practice. ;)
$vbulletin->input->clean_gpc('c', 'register_referrer', TYPE_STR);
$vbulletin->url = ($vbulletin->GPC['register_referrer']) ? $vbulletin->GPC['register_referrer'] : $vbulletin->url;
}