I am trying to figure out how to set my session_id variable to to be used in an external js file. Here is what I have.
php file:
$output = '<script src="test.js">
var session_id = '.$_SESSION['id'].'
</script>';
print $output;
js file:
alert(session_id);
With this I am getting an error saying session_id is not defined. Is there a way to pass this info across?
I know I could just setup a hidden input with the info but I am thinking there is a better way of doing it.