title: Pass javascript variable via cookie to another page and retrieve using php
body: <p>I am using Google Maps API v3 to set a marker and I am having trouble submitting the marker coordinates to a MYSQL database via PHP. I am trying to pass the javascript value for "event.latlng" to the submission page via a cookie. Since PHP is loaded server-side first, I can't use PHP to pass the variable via URL to the submission page. So I am passing the static variables via PHP to the submission page. I can't get the cookie part working though. I thought that with a javascript function dedicated to retrieving the current coordinates of the marker and placing them in a cookie, I could call that function with onclick in a href button submission link. No luck so far. "mapNew4.php" is the page I have the map on, "saveLocation.php" is the submission (to the database via PHP) page. This is the important parts of the "mapNew4.php" page. I haven't tried to retrieve the cookie yet on the "saveLocation.php" page because this code already causes the "mapNew4.php" page to stop loading. Everything else works fine without the addition of the javascript function and onclick call.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function myLatLng()
  {
  var myLatLng = event.latLng;
  setcookie('mapNew4['myLatLng']', time()+(10), '/');
  return false;
  };
  
  &lt;/script&gt;
  
  &lt;?php
  &lt;li&gt;
  &lt;a href="saveLocation.php/?meetID='. $meetingID .'&amp;courseID='. $courseID .'&amp;groupID='.        $groupID .'" onclick="javascript:myLatLng();"  data-icon="check" data-transition="flip"      style="background: green;"&gt;Save&lt;/a&gt;
  &lt;/li&gt;
  ?&gt;
  </code></pre>