0

I've scratched my head for an hour at this basic task. I'm slowly building up a google api lookup which triggers a google map on a seperate page. I want to pass the initial search text (via a textbox) to the map page via a session (which i think is the best way to do it?) However the function just wont set the session variable. Why can't i even set it to "yes" via the below function?

<script>
function secondFunction()   {
alert("pressed");
$_SESSION[$var] = "yes";
 }

Brad
  • 51
  • 1
  • 2
  • 9
  • 1
    Because JavaScript !== PHP ? `$_SESSION` is a PHP feature. PHP is executed on the **server**, JavaScript on the **client**. – Felix Kling Feb 28 '15 at 19:28
  • @FelixKling: Hm, don't we have a canonical duplicate target that is reverse to [How to pass variables and data from PHP to JavaScript](http://stackoverflow.com/q/23740548/1048572)? – Bergi Feb 28 '15 at 19:33
  • @Bergi: http://stackoverflow.com/q/13840429/218196 maybe? – Felix Kling Feb 28 '15 at 19:37
  • I had skimmed the previous questions but couldnt work through the answer. I think i am taking the wrong approach in: taking text via PHP to new page I will instead use form functions. – Brad Feb 28 '15 at 22:17

0 Answers0