When and where should I use session_start?

后端 未结 4 1968
滥情空心
滥情空心 2020-12-11 12:47

Exactly when and where should I use session_start() in PHP?

For example, say I have a login script that sets a session variable to tell whether or not t

4条回答
  •  旧时难觅i
    2020-12-11 13:36

    The session_start() function can go anywhere in your code. You should just place it at the beginning of your document for consistency and call it a day. If you have a separate database or config file you are including on all your login/database driven pages, you should place it in there so you don't have to recode it into every page.

提交回复
热议问题