Welcome Guest, Not a member yet? Register   Sign In
Missing Post Value
#1

[eluser]ci_user[/eluser]
Ok...totally strange. I'm sending the csrf_test_name value via ajax but I can not access it?
Code:
$.ajax({
type:"POST",
url: "http://localhost/mycontroller",
cache: false,
data:  {
        email: $("#email").val(),
        csrf_test_name: $("input:hidden[name='csrf_test_name']").val()
},
At this point client side the value exists and I see it when I do:
Code:
alert($("input:hidden[name='csrf_test_name']").val());
Now in my controller for some reason the value is empty:
Code:
die($this->input->post('csrf_test_name'));
However, the email value is there:
Code:
die($this->input->post('email'));

If anybody can see a reason I can get the email value but not the csrf_test_name value I sure would appreciate it!
#2

[eluser]weboap[/eluser]
check the console (firebug or chrome web develop)to what is posted
#3

[eluser]ws212[/eluser]
Not sure if it help but why don't you use id for the crsf_test_name like the email part? like
Code:
$('#crsf_test_name').val();
personally i like all my input have an id...
#4

[eluser]kanjimaster[/eluser]
Nothing strange about this. Codeigniter checks that it matches what it expected and if so explicitly removes it from the POST array.
#5

[eluser]ci_user[/eluser]
Thanks for that information. I didn't see that in the documentation anywhere. With csrf_protection enabled, if I open a form and then clear my session with firefox and submit the form, I get a server error page. I was trying to see if the crsf_test_name value matched so I could do something nicer than an ugly 500 error page. I guess that is not possible?




Theme © iAndrew 2016 - Forum software by © MyBB