If you want to pass the value during loading page. You can do it by appending the JS value as query variable in path (e.g. http://www.example.com/new/page?demo=true) for requesting the next page. In PHP, you can use API
drupal_get_query_parameters to read the data.
// retrieve data from www.example.com?data=value $query = drupal_get_query_parameters(); $value = $query['data'];
You can do it via a AJAX call. First you need to create a custom module, with a hook_menu() implementation. Then you can call that path via AJAX and process the value with PHP. Don't forget to filter the user input ;-)