How do I continue a session from one page to another with PHP

后端 未结 8 1564
夕颜
夕颜 2020-11-27 07:34

Ok I set up a session... but now how do I make it work on my other pages?

I tried doing

@session_start();

if(isset($_SESSION[\'$userName\'])) {

 ec         


        
相关标签:
8条回答
  • 2020-11-27 08:11

    Check that the session cookie is being sent to the browser on the first hit and getting returned by the browser in subsequent requests. There are lots of reasons why this may be failing - typically PHP has flushed the headers before the call to session_start() (which may be due to UTF-8 BOM chars or just messy programming).

    Make sure you've got error reporting enabled.

    C.

    0 讨论(0)
  • 2020-11-27 08:12

    Make sure both pages are on the same domain. Even www.site.com is different than site.com

    Using echo session_id(); also helps identifying your session_id on each page, make sure there are the same

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