build( Config::get('CAPTCHA_WIDTH'), Config::get('CAPTCHA_HEIGHT') ); // write the captcha character into session Session::set('captcha', $captcha->getPhrase()); // render an image showing the characters (=the captcha) header('Content-type: image/jpeg'); $captcha->output(); } /** * Checks if the entered captcha is the same like the one from the rendered image which has been saved in session * @param $captcha string The captcha characters * @return bool success of captcha check */ public static function checkCaptcha($captcha) { if ($captcha == Session::get('captcha')) { return true; } return false; } }