I am trying to pass a PHP Session variable into a js function but failing.
Here's what I'm trying. The desired end result is that it reads the correct JSON file based on user logged in details.
Is this even possible?
var username = <?=$_SESSION[username]?>;
$('#aboutContent').redactor({
imageGetJson: '/users/'+username+'/gallery/gallery.json'
});
}
I've also tried:
imageGetJson: '/users/<?=$_SESSION[username]?>/gallery/gallery.json'
But still no dice.
UPDATE - FIXED
The problem was that this js was in an external file, not in the same file where the session_start is called - so i moved it into the file as opposed to extrenal and all is good now. Using this and works perfectly (don't need to set var username):
imageGetJson: '/users/<?=$_SESSION['username']?>/gallery/gallery.json'