I want to access PHP session variables through jQuery. What is the best way to do so?
2 Answers
<?php
echo json_encode($_SESSION);
?>
Be careful what you store in the session though. ;)
1 Comment
Charles
On one hand, this is completely correct. On the other hand, this is a horrible, horrible idea. On the third hand, if the OP really wants this, then he or she gets what she or he deserves. On the fourth hand why do I have more than two hands.
https://github.com/zhangjiayin/php_session_json_handler/
PHP EXTENSION FOR SESSION WITH JSON FORMAT SAERIALIZE
config php.ini
session.serialize_handler = json
maybe help you,try it?