php - Preventing CSRF and XSRF Attacks for jQuery $.post -


i hit simple csrf attack , realized lot of ajax scripts open. these accessed on site $.post().

is there way automatically add php token of these or need go through , one-by-one?

using bwoebi's answer, found better solution. jquery has built in setup function ajax.

<script>var token ="<?= $_session['token'] ?>";</script> <script> jquery.ajaxsetup({     data: {         token: token     } }); </script> 

this add token every jquery request!


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -