title: anti-CSRF token and Javascript
body: <p>I'm trying to protect an application (php and lots of JS) from CSRF.</p>
  
  <p>I want to use tokens.</p>
  
  <p>A lot of operations are done with AJAX, so I have to pass the token in Javascript.
  If I want to generate 1 token per session or per page load it's simple - I generate new token, put it somewhere in a DOM and then find it with Javascript and send to the processing side.</p>
  
  <p>But what if I want to use new token for every operation?
  I was thinking about doing an ajax call to regenerate token and then pass the result to processing page.</p>
  
  <p>Does this increase security risk?
  I was thinking about luring user to page with script which would ask for token and then use it to make the request but then again cross domain Javascript is forbidden.
  Can it be done with flash?</p>
  
  <p>Maybe another approach for protecting ajax calls from CSRF?</p>
  
  <p>Thanks!</p>