Magento Cron: Captcha Delete Old Attemps

Magento Cron Job Name: captcha_delete_old_attemps

  • Detailed Explanation:
  • When an administrator enters correct credentials but enter the wrong captcha, it counts against you as a Login Attempt. This count is get stored in table named ‘captcha_log’ with value and time. The role of captcha_delete_old_attemps cron job is to remove all entries of login attempt from ‘captcha_log’ table.

    Now, we will see how this cron remove all entries.


    This line fetching collection of ‘captcha_log’ table.

     public function deleteOldAttempts()
             $this->_getWriteAdapter()->delete($this->getMainTable(),array('updated_at <?'
             =>Mage::getSingleton('core/date')->gmtDate(null, time() - 60*30)));

    time():1402407940 (In this case, this is time when cron is executed in timestamp)
    time() – 60*30:1402406403 (In timestamp)
    gmtDate(null):Convert timestamp to date/time format

    DELETE FROM `captcha_log` WHERE (updated_at < '2014-06-10 20:01:15')

    This function removes the record from table ‘captcha_log’ which was updated before current time.

  • XML of cron job as in config.xml is:-captcha_delete_old_attemps_config
  • From this we can make out that this job will be executed every in every 30 minuets.

  • Function Code:-
  •  public function deleteOldAttempts()
                    return $this;
  • Database related comments :-

    ‘captcha_log’: This table is count the attempt the captcha.

    Sql query to delete:-

    DELETE FROM `captcha_log` WHERE (updated_at < '2014-06-10 20:01:15')

    Schema of Table:

    Field Type Null Key Default
    type Varchar(32) No None
    value Varchar(32) No None
    count int(10) No 0
    updated_id timestamp yes Null


    type value count Updated_at
    2 fdfdfd 1 2014-06-10 13:04:27
By |2018-04-21T05:27:56+00:00June 17th, 2014|Blogs, Magento, Oscp-Blog|0 Comments