Reputation: 71
How to get the value of session in jquery. i have used this <%Response.Write(Session('toptabValue'))%> for getting value but cant get the value.
Upvotes: 1
Views: 726
Reputation: 1084
IN PHP, you can do it like this: (script should be top of js file)
<script>
var sessionData = '<?php echo $session['toptabValue']; ?>';
</script>
now you can use the
sessionData
variable in any js file.
Upvotes: 2
Reputation: 491
A secure way of accessing the session ID in JavaScript is by setting a (preferably non-global) variable with the value of the session ID and use that variable in your scripts.
Using the session ID as form token enables an attacker to steal the session ID through XSS.
Upvotes: 0
Reputation: 2821
Store this value in an hidden field and use the value of that field.
Upvotes: 4