Here\'s javascript code that i have
var randomnum = 30;
and here\'s PHP code
You can't access Session directly in JavaScript.
You can make a hidden field and pass it to your page and then use JavaScript to retrieve the object via document.getElementById