Assign Javascript Variable Value to PHP Variable

Hi guys Today, I will tell you through this tutorial how you can get the variable of javascript in php variable value.
First of all, you can create a php file. You can keep any name for this file.

variable.php

<script> 
var myJavascriptVar = '123456';
document.cookie = "myJavascriptVar = " + myJavascriptVar </script>

<?php
echo $myPhpVar= $_COOKIE['myJavascriptVar'];
?>