Welcome Guest, Not a member yet? Register   Sign In
csrf regenrate in ajax post
#6

Maybe something like this, not tested.

Code:
$(function($) {

    // this script needs to be loaded on every page where an ajax POST may happen

    $.ajaxSetup({
        data: {
            // you would need to load the Security Lib in the Controller.
            '<?php echo $security->getCSRFTokenName(); ?>' :
            '<?php echo $security>getCSRFHhash();?>'
        }
    });

    // now write your ajax script

});

Not sure if the view would see the security lib from the controller.

I'll play around with this later on.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
csrf regenrate in ajax post - by cilux - 05-15-2020, 01:27 PM
RE: csrf regenrate in ajax post - by seunex - 05-15-2020, 07:57 PM
RE: csrf regenrate in ajax post - by cilux - 05-16-2020, 12:46 AM
RE: csrf regenrate in ajax post - by InsiteFX - 05-16-2020, 03:14 AM
RE: csrf regenrate in ajax post - by cilux - 05-16-2020, 05:28 AM
RE: csrf regenrate in ajax post - by InsiteFX - 05-16-2020, 07:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB