Assuming you’re talking about a non-AJAX implementation, and retrieving the variables from Javascript after a page reload… Use the javascript to write out a value into a hidden form field, and use PHP to retrieve it from the $_POST.
so i want it super light to reduce pageloads so no jquery or other library containing non essential content
and cant use a standard form because the script will be included on remote webpages and is supposed to require no action on the users behalf
(this post just got moved from the PHP part of the forum)