Ich versuche exprimentation mit , weil ich jedes gute Feature in diesem Framework implementieren möchte, um meine Website von SQL-Injektion und Malicious Attack von Hackern da draußen zu vermeiden.Codeigniter get_csrf_hash() Rückgabe leer
Frage:
Warum, wenn ich versuche thisget_csrf_hash()
, Echo oder print_r es nicht nur etwas erscheinen.
Mein aktueller Codes
mein Controller
<?php
class Myclass extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('session');
$this->load->helper('security');
$this->load->helper('form');
$this->my_simple_login->chek_login();
}
public function index(){
$this->load->view('/myform');
} // end index function (show form)
function submit_form(){
print_r($this->input->post('my_input')); // YEAH
print_r($this->input->post('csrf_test_name')); //empty??
print_r($this->security->get_csrf_hash()); //empty??
} //end form submitted
} // end class
My View
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<head></head><body>
<?php
$attributes = array('class' => 'my_html_class'); // add class to form HTML
echo form_open_multipart('myclass/submit_form', $attributes);
?>
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
<input name="my_input" value="YEAH"/>
<button type="submit" >SUBMIT FORM</button>
<?php echo form_close(); ?></body></html>
Mein CI Config
$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
Wenn Sie form_open_multipart CSRF es automatisch Sie – user4419336
andere csrf Eingang schaffen nicht erzeugt wird, müssen das ist so gemein, auch Eingang ich schaffen nicht csrf es funktioniert. Aber wieso 'get_csrf_hash()' nicht anyting (mit oder nicht mit csrf Eingabe auf meinem Formular) zurückgeben. @ wolfgang1983 –