Index: trunk/outerbridge-humancaptcha.php =================================================================== --- trunk/outerbridge-humancaptcha.php (revision 2431647) +++ trunk/outerbridge-humancaptcha.php (working copy) @@ -186,7 +186,11 @@ $selected = $this->obr_select_question(); $question = $selected['question']; $answer = $selected['answer']; + if (!session_id()){ + session_start(); + } $_SESSION['obr_answer'] = md5(strtolower(trim($answer))); + session_write_close(); // use the comment-form-email class as it works better with 2011 $outputfield = '

'; $fields['obr_hlc'] = $outputfield; @@ -217,7 +221,11 @@ $selected = $this->obr_select_question(); $question = $selected[ 'question' ]; $answer = $selected[ 'answer' ]; + if (!session_id()){ + session_start(); + } $_SESSION[ 'obr_answer' ] = md5( strtolower( trim( $answer ) ) ); + session_write_close(); $outputfield = '


'; echo $outputfield; $fields[ 'obr_hlc' ] = $outputfield; @@ -243,14 +251,15 @@ } function obr_register_validate_answer($errors, $sanitized_user_login, $user_email){ - if (!session_id()){ - session_start(); - } if ((!isset($_POST['answer'])) || ($_POST['answer'] == '')){ $errors->add('obr_error', __('Error: please fill the required field (humancaptcha).', 'humancaptcha')); } else { $user_answer = md5(strtolower(trim($_POST['answer']))); + if (!session_id()){ + session_start(); + } $obr_answer = strtolower(trim($_SESSION['obr_answer'])); + session_write_close(); if ($user_answer != $obr_answer){ $errors->add('obr_error', __('Error: your answer to the humancaptcha question is incorrect.', 'humancaptcha')); } @@ -266,14 +275,15 @@ } function obr_validate_answer(){ - if (!session_id()){ - session_start(); - } if ((!isset($_POST['answer'])) || ($_POST['answer'] == '')){ wp_die(__('Error: please fill the required field (humancaptcha).', 'humancaptcha')); } $user_answer = md5(strtolower(trim($_POST['answer']))); + if (!session_id()){ + session_start(); + } $obr_answer = strtolower(trim($_SESSION['obr_answer'])); + session_write_close(); if ($user_answer != $obr_answer){ wp_die(__('Error: your answer to the humancaptcha question is incorrect. Use your browser\'s back button to try again.', 'humancaptcha')); } @@ -483,9 +493,6 @@ } function obr_init(){ - if (!session_id()){ - session_start(); - } global $comments_on, $register_on, $login_on; // see obr_insert_default_admin_data for which setting is which... $comments_on = $this->obr_get_setting_value(1);