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)
Hidden form fields, where you set the value via JS
Give more info and we can be more specific.
You could use a cookie. How the exchange takes place (AJAX, page reload, whatever) is up to you.
in PHP: see setcookie()
in JS: see document.cookie - or perhaps a JS library such as Dojo / jQuery.
Use AJAX. But remember, never trust data coming in from GET or POST and always run the data through a security check before using or storing it.
look into jquery, this will make your this easier!
or you could set a hidden input's value in a form and submit.
©2020 All rights reserved.