Javascript Value To PHP variable : javascript code

    	<script type="text/javascript">
    $("#test").click(function() {
      getQuerystring(this);
      return false;
    });
    
    function getQuerystring(el) {
      console.log(el.href);
      var getUrlParameter = function(sParam) {
        var sPageURL = el.href.split('?')[1],
          sURLVariables = sPageURL.split('&'),
          sParameterName;
          
        for (var i = 0; i < sURLVariables.length; i++) {
          sParameterName = sURLVariables[i].split('=');
    
          if (sParameterName[0] === sParam) {
            return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
          }
        }
      };
    
      var blog = getUrlParameter('c');
      //document.getElementById('detail').innerHTML = blog;
      document.cookie = "blog = " + blog;
    }
    </script>
html code

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <div style="border: dashed; size: auto;">
      <a name="divtest" href="#detail?c=active" id="test">testing</a>
    </div>
    <div id="detail" style="border: 2px; size: auto;">
    	<?php
    	$chk = $_COOKIE['blog'];
    	echo $chk;
    	?>
    </div>
the javascript code should set the cookie. and then php get the values saved in the cookie. i basically wants to send value from javascript to php on same page. but it seems to be an error" Notice: Undefined index: blog in C:\wamp64\www\test\ajax.php on line 40".i hae searched alot but didnt find proper solution.kindly help me correcting my code. i will be thankful to you.