开发者

Why is $_SESSION not carrying data to separate PHP file?

开发者 https://www.devze.com 2023-03-09 15:00 出处:网络
I have a login page that sets a $_SESSION[\'usertype\'] w开发者_高级运维hen I log in. I have a separate PHP file that contains a menu that loads on the side. That file is loaded on every PHP file thro

I have a login page that sets a $_SESSION['usertype'] w开发者_高级运维hen I log in. I have a separate PHP file that contains a menu that loads on the side. That file is loaded on every PHP file through

<?php include('menu.php') ?>

But when I check for $_SESSION['usertype'] in menu.php, it is not set.

Why is this?


Just checking whether you're using session_start() before you include the file which needs to access $_SESSION['usertype']?

Have a check through this tutorial.


Do you have session_start() at the top of menu.php or before the include of menu.php?

0

精彩评论

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

关注公众号