jrCore_set_csrf_cookie(url) sets the CSRF cookie for a URL, without going there. Use it before an AJAX request to a view that calls jrCore_validate_location_url(). jrCore_window_location() uses it too.
function xxMyModule_toggle(id)
{
var url = core_system_url + '/' + xxMyModule_url + '/toggle/id=' + id + '/__ajax=1';
jrCore_set_csrf_cookie(url);
$.post(url, {}, function(res) {
// ...
});
}And in the view:
function view_xxMyModule_toggle($_post, $_user, $_conf)
{
jrUser_session_require_login();
jrCore_validate_location_url();
// ...
}Another site can't set cookies for your domain, so a forged request fails the check.