45 global $dolibarr_main_db_type, $dolibarr_main_db_host;
46 global $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name, $dolibarr_main_db_port;
48 global $dolibarr_session_db_type, $dolibarr_session_db_host;
49 global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port;
51 if (empty($dolibarr_session_db_type)) {
52 $dolibarr_session_db_type = $dolibarr_main_db_type;
54 if (empty($dolibarr_session_db_host)) {
55 $dolibarr_session_db_host = $dolibarr_main_db_host;
57 if (empty($dolibarr_session_db_user)) {
58 $dolibarr_session_db_user = $dolibarr_main_db_user;
60 if (empty($dolibarr_session_db_pass)) {
61 $dolibarr_session_db_pass = $dolibarr_main_db_pass;
63 if (empty($dolibarr_session_db_name)) {
64 $dolibarr_session_db_name = $dolibarr_main_db_name;
66 if (empty($dolibarr_session_db_port)) {
67 $dolibarr_session_db_port = $dolibarr_main_db_port;
71 $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);
85 global $sessionlastvalueread;
86 global $sessionidfound;
88 $sql =
"SELECT session_id, session_variable FROM ".MAIN_DB_PREFIX.
"session";
89 $sql .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
92 $resql = $dbsession->query($sql);
93 $num_rows = $dbsession->num_rows($resql);
96 $sessionlastvalueread =
'';
101 $obj = $dbsession->fetch_object($resql);
102 $sessionlastvalueread = $obj->session_variable;
103 $sessionidfound = $obj->session_id;
106 return $obj->session_variable;
121 global $sessionlastvalueread;
122 global $sessionidfound;
129 if ($sessionlastvalueread != $val) {
132 if (empty($sessionidfound)) {
134 $insert_query =
"INSERT INTO ".MAIN_DB_PREFIX.
"session";
135 $insert_query .=
"(session_id, session_variable, last_accessed, fk_user, remote_ip, user_agent)";
136 $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)).
"')";
138 $result = $dbsession->query($insert_query);
144 if ($sessionidfound != $sess_id) {
146 dol_print_error($dbsession,
'Oops sess_id received in dolSessionWrite differs from the cache value $sessionidfound. How can this happen ?');
169 $update_query =
"UPDATE ".MAIN_DB_PREFIX.
"session";
170 $update_query .=
" SET session_variable = '".$dbsession->escape($val).
"',";
171 $update_query .=
" last_accessed = '".$dbsession->idate($time_stamp).
"',";
172 $update_query .=
" remote_ip = '".$dbsession->escape(
getUserRemoteIP()).
"',";
173 $update_query .=
" user_agent = '".$dbsession->escape($_SERVER[
'HTTP_USER_AGENT']).
"'";
174 $update_query .=
" WHERE session_id = '".$dbsession->escape($sess_id).
"'";
176 $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).