I have in session PHP:
$_SESSION['id'] = 2;
how can i get this for jQuery?
<script>
var sessionid = ??? ;
alert(sessionid);
</script>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could set it as the ID of an element (like the HTML element) if you want to access it from a script:
In the external script:
This has the added benefit of being able to be read by an external script.
EDIT:
You would need to set the session before you output anything, so the full code would be something like: