Get username from $_SESSION

后端 未结 1 1110
滥情空心
滥情空心 2021-01-28 02:13

I am trying to get the username of my users to echo out but only seeing the userID or if I try to echo the username it gives me the string length rather than the actual name.

相关标签:
1条回答
  • 2021-01-28 02:23

    the reason you do not see the user name in:

    $_SESSION['username']

    is because you never put it there.

    you need to assign the user name to the session like so:

    $_SESSION['username']=$email;

    you can then echo $_SESSION['username']; where ever you want the username displayed.

    make sure on any page you use sessions you have session_start(); before any output.

    0 讨论(0)
提交回复
热议问题