How to pass JS variable to php?

Assuming you mean JavaScript function returns a hash and sends it to PHP - then AJAX


You should give more info about what exactly you are trying to do. Like this all we can do is guess and you'll get no good answers. But the usual suspects in this case are:

  • AJAX (or JSON)

  • Cookies

  • Hidden form fields, where you set the value via JS

Give more info and we can be more specific.