Is it possible to read a session value with Javascript?
For example, if I assigned a value into a session in PHP:
$_SESSION['msg'] = "ABC Message";
Is it possible to read $_SESSION['msg']
with Javascript?
A very simple way is to generate the JavaScript with some PHP code:
<script type="text/javascript">
<?php echo 'var msg = "'.json_encode($_SESSION['msg']).'";';
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With