Sending a JavaScript variable to a PHP function I am trying to send a value in JavaScript variable to Drupal. I am calling an external js file in hook_nodeapi(). I want to send a value from this external js file to Drupal, and want to use this value in Drupal in hook_block.
For example

hook_nodeapi() {
  // call(external.js)
}
external.js
var sendData =10;

hook_block
{
  case view:
  // need to access sendData value
}


I tried this using cookies, but I think that is not the best way.
How can this be done?
Let's look at what the client can do as an alternative to setting a cookie:


Make an AJAX request that lets the server store the variable.
Add the variable name and value to the query string of every internal link and to every form submission (not just the next one).


I do not see any benefits of Solution 1, that justifies the extra HTTP request. Especially, you cannot circumvent the necessity for the user to have Cookies enabled, because the value must be stored close to the user and Drupal uses Cookies exclusively to determine the session (and thus the user).

Solution 2 allows for different values within the same session. If this is not one of your requirements, I consider this solution too much of a hassle.