3

I want to access PHP session variables through jQuery. What is the best way to do so?

2 Answers 2

5
<?php
echo json_encode($_SESSION);
?>

Be careful what you store in the session though. ;)

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.