admin管理员组文章数量:1391987
I created the nonce when I localize a script file:
wp_localize_script('cad-search', 'cad_ajax',
array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce'=> wp_create_nonce('cad_nonce'))
);
wp_enqueue_script('cad-search');
But when the nonce is evaluated in the function called through AJAX the values are not the same:
if ( !wp_verify_nonce( $_POST['nonce'], 'cad_nonce')) {
exit('Missing nonce! Please refresh the page.');
}
This code works in Firefox but not in Chrome.
I created the nonce when I localize a script file:
wp_localize_script('cad-search', 'cad_ajax',
array( 'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce'=> wp_create_nonce('cad_nonce'))
);
wp_enqueue_script('cad-search');
But when the nonce is evaluated in the function called through AJAX the values are not the same:
if ( !wp_verify_nonce( $_POST['nonce'], 'cad_nonce')) {
exit('Missing nonce! Please refresh the page.');
}
This code works in Firefox but not in Chrome.
Share Improve this question asked Feb 18, 2020 at 18:31 AlanPAlanP 7211 gold badge9 silver badges21 bronze badges 2- Does Chrome cache the page? – kero Commented Feb 18, 2020 at 18:34
- That could be a possibility since it is only happening on the front end. If so, what can be done about it? Caching would make nonces impossible to use. – AlanP Commented Feb 18, 2020 at 18:57
1 Answer
Reset to default 0Turning off a cache plugin, Fast Cache in this case, and adding 'define('WP_CACHE', false);' to the wp-config.php file seems to have resolved this issue.
本文标签: Why are nonces working in Firefox but not in Chrome
版权声明:本文标题:Why are nonces working in Firefox but not in Chrome? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744738176a2622456.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论