i'm working on a way to update some data in a custom table that updates when the cart triggers session_recreate_id
1. i've added the table name customer2_data to database_tables.php (TABLE_CUSTOMER2_DATA)
2. inserted the function name in sessions.php to trigger just before the whos_online_session_recreate($oldSessID, $newSessID);
customerIPfield_session_recreate($oldSessID, $newSessID);
whos_online_session_recreate($oldSessID, $newSessID);
3. added an extra_function that sorta parallels the whos_online_session_recreate function but first checks for the customer's IP, if it finds the customer's IP in the customer2_data customerIP field, then it should update the session id in that table row too:
PHP Code:
function customerIPfield_session_recreate($old_session, $new_session) {
global $db;
$customer_ip_current = $_SERVER['REMOTE_ADDR'];
$sql = "select customerIP from " . TABLE_CUSTOMER2_DATA . " where customerIP = :customer_ip_current";
$sql = $db->bindVars($sql, ':customer_ip_current', $customer_ip_current, 'noquotestring');
$result = $db->Execute($sql);
if ($result->RecordCount() > 0) {
$sql = "UPDATE " . TABLE_CUSTOMER2_DATA . "
SET session_id = :newSessionID
WHERE session_id = :oldSessionID
AND customerIP = :customer_ip_current";
$sql = $db->bindVars($sql, ':newSessionID', $new_session, 'string');
$sql = $db->bindVars($sql, ':oldSessionID', $old_session, 'string');
$sql = $db->bindVars($sql, ':customer_ip_current', $customer_ip_current, 'noquotestring');
$db->Execute($sql);
} else {
//
//
}
}
However, when I add something to the cart and then try to login (triggering session recreate), I get the following error:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.56.789' at line 1
in:
[select customerIP from customer2_data where customerIP = 123.34.56.789]
any idea what be the issue? i've tweaked a few things but keep getting the same error
thanks