View Full Version : Parameter passing from server side php to client side javascript

08-22-2011, 06:54 PM
Hi people,
I need help as follows:

On the server side I have a php generated session parameter.
I need to pass it to javascript on the client side page.

I saw on the web the following solution:

<script language="JavaScript">
var mySessionVar="<%= Session["MySessionVar"] %>";

I tried it but it did not work.

I could not find any explanation of this syntax - will appreciate one.

Any suggestions, maybe in another way?


08-22-2011, 07:21 PM
Long time ago I used PHP ... but <% is most definitely not PHP. Neither is Session[] which should be $_SESSION[] in PHP afaik.

Try this:

var mySessionVar="<?=$_SESSION['MySessionVar']; ?>";