I am trying to get the user session from a PHP script into jQuery, but the result is empty. If I use the code in a PHP script it is working properly.
How can I make this work?
<script>
jQuery(document).ready(
function(){
var user = '<?php echo $_SERVER['LOGON_USER']; ?>';
alert(user);
$('#answer83148X78X346').val(user);
}
);
</script>
LOGON_USERcontains a single quote, I wonder? )addslashes($_SESSION['LOGON_USER'])var user = <?= json_encode($_SESSION['LOGON_USER']) ?>;.