Q:

How to get the php session data in javascript function of a .js file

I want to take the session data in .js file.Here i want the data in a function
Now i'm directly put the value.How to take it from session.
.js file
  function callAllfnt(){ 
   get_data(1) ;
  }

I want the 1 as session data.How to take it

A:

If you want it on page load the try this:
function callAllfnt() {
  var data = "<?php echo $_SESSION['givenName']; ?>";
}

In later part in the life cycle of the application, use AJAX

