Here it is:
function write($key, $value)
{
$expiry = time() + $this -> sessLife;
$value = addslashes($value);
$sql = sprintf("update %s set %s, %s, %s where %s and %s",
"sessions", sprintf("expiry=%d", $expiry), sprintf("value='%s'", $value), sprintf("address='%s'", cntRemHost),
sprintf("id='%s'", $key), sprintf("expiry>%d", time()));
$this -> conn -> query($sql);
$affected = $this -> conn -> affected();
if ($affected == 0) {
$sql = sprintf("insert into %s (%s,%s,%s,%s) values ('%s',%d,'%s','%s')",
"sessions", "id", "expiry", "value", "address",
$key, $expiry, $value, cntRemHost);
return $this -> conn -> query($sql);
} else {
return true;
}
}
it is actually a member function, which really makes no difference. There are certain variables that are worth explaining: $this->conn is just a object of a class i wrote for db access, cntRemHost is just a constant that has the users Remote Address. Basically, the function first try's to do an update, if it doesn't work, it means that the key doesn't exist, so it then inserts it.
As i said before, the function is not the problem. I know for a fact that the encoded session data passed to write() in the arguement $value is the problem. I assign something to $_SESSION, and it's not reflected in this encoded data.