Mistah Roth
06-29-2007, 12:39 PM
So I finally have a somewhat working script that replicated the method in which vBulletin sets and stores sessions. The main algorithm is here:
$_SESSION['lastactivity'] = strtotime(date('dS M Y, H:i:s', $_SERVER['REQUEST_TIME']));
$_SESSION['sessionhash'] = md5($_SESSION['lastactivity'] . $_SERVER['REQUEST_URI'] . $_SESSION['idhash'] . $_SERVER['REMOTE_ADDR'] . rand(1, 1000000));
$sql = ("INSERT INTO `session` ( `sessionhash` , `userid` , `host` , `idhash` , `lastactivity` , `location` , `useragent`) VALUES ('".$_SESSION['sessionhash']."', '".$_SESSION['id']."', '".$_SERVER['REMOTE_ADDR']."', '".$_SESSION['idhash']."', '".$_SESSION['lastactivity']."', '".$_SERVER['REQUEST_URI']."', '".$_SERVER['HTTP_USER_AGENT']."')");
mysql_query($sql) or die(mysql_error());
This works for the most part, the ID hash is identical to the one that vBulletin sets, and I believe the sessionhash is correct as well.
When someone visits the forum, then goes to the non-vB site, the site grabs the session values OK
When someone logs into the forums, then goes to the site, the site grabs the session values OK
When someone visits the site, then goes to the forum, the forum grabs the session values OK
Where it messes up is when a user logs on to the site, then visits the forum, the forum creates a new session for the user (one that is not logged in).
Logging in sets session values in the database, as well as matching cookie values all properly, anyone know why the log in isn't transfering to the forums?
$_SESSION['lastactivity'] = strtotime(date('dS M Y, H:i:s', $_SERVER['REQUEST_TIME']));
$_SESSION['sessionhash'] = md5($_SESSION['lastactivity'] . $_SERVER['REQUEST_URI'] . $_SESSION['idhash'] . $_SERVER['REMOTE_ADDR'] . rand(1, 1000000));
$sql = ("INSERT INTO `session` ( `sessionhash` , `userid` , `host` , `idhash` , `lastactivity` , `location` , `useragent`) VALUES ('".$_SESSION['sessionhash']."', '".$_SESSION['id']."', '".$_SERVER['REMOTE_ADDR']."', '".$_SESSION['idhash']."', '".$_SESSION['lastactivity']."', '".$_SERVER['REQUEST_URI']."', '".$_SERVER['HTTP_USER_AGENT']."')");
mysql_query($sql) or die(mysql_error());
This works for the most part, the ID hash is identical to the one that vBulletin sets, and I believe the sessionhash is correct as well.
When someone visits the forum, then goes to the non-vB site, the site grabs the session values OK
When someone logs into the forums, then goes to the site, the site grabs the session values OK
When someone visits the site, then goes to the forum, the forum grabs the session values OK
Where it messes up is when a user logs on to the site, then visits the forum, the forum creates a new session for the user (one that is not logged in).
Logging in sets session values in the database, as well as matching cookie values all properly, anyone know why the log in isn't transfering to the forums?