How to access PHP session variables from jQuery function in a .js file? In this code, I want to get \"value\" from a session variable
$(function() {
$(\"#
I was struggling with the same problem and stumbled upon this page. Another solution I came up with would be this :
In your html, echo the session variable (mine here is =$_SESSION['origin'];?>$_SESSION['origin']) to any element of your choosing :
In your js, using jQuery you can access it like so :
$("#sessionOrigin").text();
EDIT: or even better, put it in a hidden input