40 global $dolibarr_main_db_type, $dolibarr_main_db_host;
41 global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port;
43 global $dolibarr_session_db_type, $dolibarr_session_db_host;
44 global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port;
46 if (empty($dolibarr_session_db_type)) { $dolibarr_session_db_type = $dolibarr_main_db_type; }
47 if (empty($dolibarr_session_db_host)) { $dolibarr_session_db_host = $dolibarr_main_db_host; }
48 if (empty($dolibarr_session_db_user)) { $dolibarr_session_db_user = $dolibarr_main_db_user; }
49 if (empty($dolibarr_session_db_pass)) { $dolibarr_session_db_pass = $dolibarr_main_db_pass; }
50 if (empty($dolibarr_session_db_name)) { $dolibarr_session_db_name = $dolibarr_main_db_name; }
51 if (empty($dolibarr_session_db_port)) { $dolibarr_session_db_port = $dolibarr_main_db_port; }
54 $dbsession =
getDoliDBInstance($dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, (
int) $dolibarr_session_db_port);
68 global $sessionlastvalueread;
69 global $sessionidfound;
71 $sql =
"SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX.
"session";
72 $sql .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
75 $resql = $dbsession->query($sql);
76 $num_rows = $dbsession->num_rows($resql);
79 $sessionlastvalueread =
'';
84 $obj = $dbsession->fetch_object($resql);
85 $sessionlastvalueread = $obj->session_variable;
86 $sessionidfound = $obj->session_id;
89 return $obj->session_variable;
104 global $sessionlastvalueread;
105 global $sessionidfound;
112 if ($sessionlastvalueread != $val) {
115 if (empty($sessionidfound)) {
117 $insert_query =
"INSERT INTO ".MAIN_DB_PREFIX.
"session";
118 $insert_query .=
"(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)";
119 $insert_query .=
" VALUES ('".$dbsession->escape($sess_id).
"', '".$dbsession->escape($val).
"', '".$dbsession->idate($time_stamp).
"', 0, '".$dbsession->escape(
getUserRemoteIP()).
"', '".$dbsession->escape(substr($_SERVER[
'HTTP_USER_AGENT'], 0, 255)).
"')";
121 $result = $dbsession->query($insert_query);
127 if ($sessionidfound != $sess_id) {
129 dol_print_error($dbsession,
'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?');
152 $update_query =
"UPDATE ".MAIN_DB_PREFIX.
"session";
153 $update_query .=
" SET session_variable = '".$dbsession->escape($val).
"',";
154 $update_query .=
" last_accessed = '".$dbsession->idate($time_stamp).
"',";
155 $update_query .=
" remote_ip = '".$dbsession->escape(
getUserRemoteIP()).
"',";
156 $update_query .=
" user_agent = '".$dbsession->escape($_SERVER[
'HTTP_USER_AGENT']).
"'";
157 $update_query .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
159 $result = $dbsession->query($update_query);
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDoliDBInstance($type, $host, $user, $pass, $name, $port)
Return a DoliDB instance (database handler).