PHP: session isn't saving before header redirect

后端 未结 10 1254
死守一世寂寞
死守一世寂寞 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 18:09

    I know this is an old toppic but I found the solution (for me). I've put a exit after the header.

    $_SESSION['session'] = 'this is a session';
    header('location: apage.php');
    exit;
    

    This works for me

提交回复
热议问题