46 global $dolibarr_main_db_type, $dolibarr_main_db_host;
47 global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port;
49 global $dolibarr_session_db_type, $dolibarr_session_db_host;
50 global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port;
52 if (empty($dolibarr_session_db_type)) {
53 $dolibarr_session_db_type = $dolibarr_main_db_type;
55 if (empty($dolibarr_session_db_host)) {
56 $dolibarr_session_db_host = $dolibarr_main_db_host;
58 if (empty($dolibarr_session_db_user)) {
59 $dolibarr_session_db_user = $dolibarr_main_db_user;
61 if (empty($dolibarr_session_db_pass)) {
62 $dolibarr_session_db_pass = $dolibarr_main_db_pass;
64 if (empty($dolibarr_session_db_name)) {
65 $dolibarr_session_db_name = $dolibarr_main_db_name;
67 if (empty($dolibarr_session_db_port)) {
68 $dolibarr_session_db_port = $dolibarr_main_db_port;
72 $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);
86 global $sessionlastvalueread;
87 global $sessionidfound;
89 $sql =
"SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX.
"session";
90 $sql .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
93 $resql = $dbsession->query($sql);
94 $num_rows = $dbsession->num_rows($resql);
97 $sessionlastvalueread =
'';
102 $obj = $dbsession->fetch_object($resql);
103 $sessionlastvalueread = $obj->session_variable;
104 $sessionidfound = $obj->session_id;
107 return $obj->session_variable;
122 global $sessionlastvalueread;
123 global $sessionidfound;
130 if ($sessionlastvalueread != $val) {
133 if (empty($sessionidfound)) {
135 $insert_query =
"INSERT INTO ".MAIN_DB_PREFIX.
"session";
136 $insert_query .=
"(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)";
137 $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)).
"')";
139 $result = $dbsession->query($insert_query);
145 if ($sessionidfound != $sess_id) {
147 dol_print_error($dbsession,
'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?');
170 $update_query =
"UPDATE ".MAIN_DB_PREFIX.
"session";
171 $update_query .=
" SET session_variable = '".$dbsession->escape($val).
"',";
172 $update_query .=
" last_accessed = '".$dbsession->idate($time_stamp).
"',";
173 $update_query .=
" remote_ip = '".$dbsession->escape(
getUserRemoteIP()).
"',";
174 $update_query .=
" user_agent = '".$dbsession->escape($_SERVER[
'HTTP_USER_AGENT']).
"'";
175 $update_query .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
177 $result = $dbsession->query($update_query);
dol_print_error($db=null, $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).