WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problems getting new nonce for Ajax requests (2 posts)

  1. redrocksrover2
    Member
    Posted 1 year ago #

    I'm experiencing maddening problems in getting WordPress to generate a new nonce for subsequent Ajax requests to process a specific action. I've tried setting the nonce_life to something reasonably short, but that has caused other problems. I've tried creating a new nonce for the callback function with a unique timestamp or something similar, but then the value of the nonce can't be compared against its name in the subsequent request.

    At this stage I don't know what to do. None of the suggestions I've read elsewhere from other folks are working-- implementing those suggestions results in WordPress continuing to spit out a nonce that was the same as before.

    I've referenced:

    1) http://www.techytalk.info/securing-your-wordpress-plugin-ajax-calls-using-nonces/

    2) http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/

    3) http://wp.tutsplus.com/tutorials/creative-coding/capabilities-and-nonces/

    4) http://wordpress.stackexchange.com/questions/14751/ajax-why-multiple-calls-to-wp-create-nonce-return-same-value

  2. bcworkz
    Member
    Posted 1 year ago #

    As it turns out, the WordPress nonce is not a number used once, it is number used as many times as you need in a 24 hour period. The factors used to create a nonce are what day it is, the user ID, and the string you provide to the create nonce function to differentiate it from other nonces. As long as none of these things change, you can keep using the same nonce any number of times.

    So failure to update your nonce after one use would not prevent you from doing the same action any number of times, there may be some other issue manifesting itself.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags