Regarding doing this in PHP... I started to write something along the same lines, then got distracted. Here's what I have, but I haven't really tried it out yet. Might be a helpful starting point, though:
PHP Code:
$timenow = time();
if(!isset($_SESSION["next_forum_login_request"])) $_SESSION["next_forum_login_request"] = 0;
if($timenow > $_SESSION["next_forum_login_request"]) {
$ch = curl_init("http://".$_SERVER["HTTP_HOST"]."/forum/login.php");
curl_setopt($ch,CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "do=login&vb_login_username=".$username."&vb_login_password=&s=&vb_login_md5password=".$pre_md5d_password."&vb_login_md5password_utf=".$pre_md5d_password);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
$result = explode("\n",curl_multi_getcontent($ch));
foreach($result as $headerline) {
if(strpos($headerline,"Set-Cookie: ") === 0) {
header($headerline);
}
}
$_SESSION["next_forum_login_request"] = $timenow + 300;
}
If you spot any glaring errors that will break everything, let me know

(and remember... I haven't tested this code, so I don't promise it works)