开发者

PHP var_dump($_SESSION);

开发者 https://www.devze.com 2023-03-14 10:16 出处:网络
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.

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.

    array(4) {
 ["SESS_ID"]=> string(1) "2"
 ["SESS_FIRST_NAME"]=> string(7) "Kevin"
 ["SESS_LAST_NAME"]=> string(6) "Outerbridge"
 ["username"]=&开发者_如何学Gogt; 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.


PHP var_dump() function will display always null for $_SESSIONS. You can use :

 Print_r ($_SESSION);

Thought it may help, Have a nice one


"Fix" what?

$_SESSION['username'] has the value "", or the empty string.

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.


$_SESSION['username'] was not echoing

It seems like it was potentially echoing an empty value because if you look in your array:

["username"]=> string(0) ""

contains an empty value


Your SESSION variable exists, but it is empty. You're filling that variable with an empty string.


Do you started the session?

session_start();


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号