Skip to navigation
How to prevent codeiginter to create databases session entries when a bot visit the site.
04.06.14
create the file application/libraries/MY_Session.php overwrite the function sess_create() change this if condition: if ($this->sess_use_database === TRUE && $this->CI->agent->is_robot() === FALSE) example: CI->input->ip_address(); $this->userdata = array( 'session_id' => md5(uniqid($sessid, TRUE)), 'ip_address' => $this->CI->input->ip_address(), 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), 'last_activity' => $this->now, 'user_data' => '' ); // Save the data to the DB if needed if ($this->sess_use_database === TRUE && $this->CI->agent->is_robot() === FALSE) { $this->CI->db->query($this->CI->db->insert_string($this->sess_table_name, $this->userdata)); } // Write the cookie $this->_set_cookie(); } }
Reply
Anonymous
Information Epoch 1732535635
When you must fail, fail noisily and as soon as possible.
Home
Notebook
Contact us