Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter Session spammed by bots

my website has visits from various search engine bots. I would like to ignore the bots from the session table.

i tried with this library https://github.com/donjakobo/codeigniter-clean-sessions but didn't work with ci 3.

Any help?

I'm not sure how well this would work, as it would depend at least somewhat on your site's ability to continue to function without a session, but you could extend the sessions library in a similar fashion to the library you linked by creating a file in /application/libraries/Session/MY_Session.php:
PHP Code:
('BASEPATH') OR exit('No direct script access allowed');

MY_Session extends CI_Session
    public function 
__construct(array $params = array())
$CI get_instance();
        if (
$CI->agent->is_robot()) {
log_message('debug''Session: Robot detected, initialization aborted.');

This also depends on the ability to access the loader (and, in turn, the user_agent library) at the time the session library is loaded.

Note that this should be the entire contents of the new file. All it does is load the user_agent library to check whether it can identify a robot. If it identifies a robot, it logs a debug message and exits. Otherwise, it turns control back over to the parent, making sure to pass along any parameters which may have been passed by the loader.

mwhitney, thank u. I use this construction, work it.
but I edit this array list
maybe somebody need this.

PHP Code:
$robots = array(
'googlebot' => 'Googlebot',
'yandex' => 'YandexBot',
'msnbot' => 'MSNBot',
'yahoo' => 'Yahoo',
'baiduspider' => 'Baiduspider',
'bingbot' => 'Bing',
'slurp' => 'Inktomi Slurp',
'ask jeeves' => 'Ask Jeeves',
'fastcrawler' => 'FastCrawler',
'infoseek' => 'InfoSeek Robot 1.0',
'lycos' => 'Lycos',
'mediapartners-google' => 'MediaPartners Google',
'CRAZYWEBCRAWLER' => 'Crazy Webcrawler',
'adsbot-google' => 'AdsBot Google',
'feedfetcher-google' => 'Feedfetcher Google',
'curious george' => 'Curious George',
'sputnikbot' => 'Sputnik',
'sosospider' => 'Soso'

I am developing an Anti-Scraping library


Just completed the document, still testing it. I will uplodad the library soon..
Personal blog: https://terryl.in
My personal project is called Dictpedia is currently using Codeigniter 3, welcome.

(This post was last modified: 05-21-2016, 01:14 PM by skunkbad.)

Maybe it is a simple solution where you have a blacklist in MY_Session.php:

class MY_Session extends CI_Session {

    public function __construct(array $params = array())
        $CI =& get_instance();

        $blacklist = [

        foreach( $blacklist as $bot )
                stripos( $_SERVER['HTTP_USER_AGENT'], $bot ) !== FALSE OR
                $CI->input->ip_address() == $bot


Theme © iAndrew 2016 - Forum software by © MyBB