如何使用firebug查看php中的会话详细信息? [英] How to view session details in php using firebug?
本文介绍了如何使用firebug查看php中的会话详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我该如何做:
console.log('<?php print_r($_SESSION); ?>');
在控制台中查看结果。
console.log('<?php echo serialize($_SESSION); ?>');
是否有一种方法可以在firebug中回显会话信息,或者在chrome中检查元素以进行测试?
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?
推荐答案
this:
<script>
console.log(<?php echo json_encode($_SESSION, JSON_HEX_TAG); ?>);
</script>
不需要引号。另请参见 Firebug和日志。
No quotes are required. See as well Firebug and Logging.
[edit,May 2014]更新了对XSS攻击安全的代码。 始终将 JSON_HEX_TAG
传递给 json_encode
通过对以下字符串进行编码,将代码插入DOM:
[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!');
这篇关于如何使用firebug查看php中的会话详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文