You cannot access session variables directly from jQuery: sessions running on the server; JavaScript works on the client.
You will have to export variables from PHP to JavaScript, for example. So:
<script>
SESSION = {
"abc": "<?php echo $_SESSION["abc"]; ?>",
"def": "<?php echo $_SESSION["def"]; ?>",
"ghi": "<?php echo $_SESSION["ghi"]; ?>",
};
alert(SESSION.abc); // will output "abc"
</script>
Be careful to export only session variables that are not security related.
source
share