PHP $_SESSION empty after header redirect

前端 未结 3 1566
生来不讨喜
生来不讨喜 2021-01-20 12:36

I\'m losing the data in $_SESSION when I do a header redirect. When I walk through this with a debugger I can see all my data in $_SESSION before I exit();

相关标签:
3条回答
  • 2021-01-20 13:06

    Make sure you are using the function session_start(); before the if-statement on myaccount.php

    0 讨论(0)
  • 2021-01-20 13:12

    Yes don't delete post ... I had EXACTLY the same issue, and this post caused me to involuntarily smack palm firmly against forehead. And it fixed the problem (with my code that is, not my dumbness). Cheers!

    0 讨论(0)
  • 2021-01-20 13:26

    You should call session_start() on every page accessing (that is, reading or writing) $_SESSION, and call it before any access to the session array. So, be sure you call session_start() on both pages.

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