How to view session details in php using firebug?

蓝咒 提交于 2019-12-07 20:16:46

问题


I'm trying to figure out I how can do something like:

console.log('<?php print_r($_SESSION); ?>'); 

To see the results in the console.

console.log('<?php echo serialize($_SESSION); ?>');

does not work either. Is there a way for me to echo the session information in firebug or inspect element in chrome for testing purposes?


回答1:


You could try this :

<script>
    console.log(<?php echo json_encode($_SESSION, JSON_HEX_TAG); ?>);
</script>

No quotes are required. See as well Firebug and Logging.


[edit, May 2014] Updated the code to be safe against XSS attacks. Always pass JSON_HEX_TAG to json_encode if you're embedding in HTML, or an attacker could inject code into the DOM by having you encode a string like:

</script><script>alert('Hello!');



回答2:


It is not possible to view the session details using fire bug.



来源:https://stackoverflow.com/questions/8674220/how-to-view-session-details-in-php-using-firebug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!