PHP var_dump($_SESSION);
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6417816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP var_dump($_SESSION);
提问by user807419
I am working on a project and the $_SESSION['username']
was not echoing I used the var_dump and this is what I got back from that result my question is how do I fix it.
我正在处理一个项目,但$_SESSION['username']
没有回应我使用了 var_dump,这就是我从该结果中得到的结果,我的问题是如何修复它。
array(4) {
["SESS_ID"]=> string(1) "2"
["SESS_FIRST_NAME"]=> string(7) "Kevin"
["SESS_LAST_NAME"]=> string(6) "Outerbridge"
["username"]=> string(0) "" }
I am sort of new to this var_dump so I am not sure if it is in your forum I will relook at all that is posted.
我对这个 var_dump 有点陌生,所以我不确定它是否在您的论坛中,我会重新查看发布的所有内容。
回答by Lightness Races in Orbit
"Fix" what?
“修”什么?
$_SESSION['username']
has the value ""
, or the empty string.
$_SESSION['username']
具有 value""
或空字符串。
If that's not what you wanted, do whatever you need to do to make that not happen.
如果这不是您想要的,请做任何您需要做的事情来避免这种情况发生。
I'm sorry that this appears like a useless answer, but really it's a useless question.
很抱歉,这似乎是一个无用的答案,但实际上这是一个无用的问题。
回答by Mihai Nedelcovici
PHP var_dump() function will display always null for $_SESSIONS. You can use :
PHP var_dump() 函数将始终为 $_SESSIONS 显示 null。您可以使用 :
Print_r ($_SESSION);
Thought it may help, Have a nice one
认为它可能会有所帮助,祝你好运
回答by Marlon
$_SESSION['username'] was not echoing
$_SESSION['username'] 没有回显
It seems like it was potentially echoing an empty value because if you look in your array:
似乎它可能会回显一个空值,因为如果您查看数组:
["username"]=> string(0) ""
contains an empty value
包含一个空值
回答by genesis
Your SESSION variable exists, but it is empty. You're filling that variable with an empty string.
您的 SESSION 变量存在,但为空。您正在用空字符串填充该变量。
回答by Heitor Giacomini
Do you started the session?
你开始会议了吗?
session_start();
回答by James Miller
In case someone needs an answer to this question. In my experience working with $_SESSION global, if you navigate from the original page of a form by opening another instance of the browser, you do not automatically get the same $_SESSION hence the variables are empty. Use the 'action' property of your form to navigate to your processing page so that you have an active session filled with the session variables. Also insure that you have session_start() in some form for each page. This can be easily misunderstood when developing.
如果有人需要这个问题的答案。根据我使用 $_SESSION 全局的经验,如果您通过打开浏览器的另一个实例从表单的原始页面导航,您不会自动获得相同的 $_SESSION,因此变量为空。使用表单的“action”属性导航到您的处理页面,以便您拥有一个充满会话变量的活动会话。还要确保每个页面都有某种形式的 session_start()。这在开发时很容易被误解。