PHP: session isn't saving before header redirect

后端 未结 10 1387
死守一世寂寞
死守一世寂寞 2020-12-06 17:26

I have read through the php manual for this problem and it seems quite a common issue but i have yet to find a solution. I am saving sessions in a database. My code is as f

10条回答
  •  醉酒成梦
    2020-12-06 17:45

    You should start the session before using the session array.

    PHP Code,
    session_start();
    $_SESSION['userID'] = $user->id;

    header('Location: /subdirectory/index.php');

提交回复
热议问题