问题描述
所以我正在创建自己的网站,并且已经制作了差不多的登录文件.我只需要弄清楚将 session_start 放在哪里以保持用户登录.我到底应该把 session_start 放在哪里?我把它放在登录文件中了吗?或者我把它放在哪里?
So I'm starting my own website and I have the login file pretty much made. I just need to figure out where to put the session_start to keep the user logged in. Where exactly do I put the session_start? Do I put it right in the login file? Or where do I put it?
感谢您的帮助
推荐答案
把它放在你的 PHP 开始标签之后 ... like this
Put it after your PHP start tag <?
... like this
<?php
session_start();
//... your code....
//more code....
阅读 PHP 手册中有关会话的更多信息.这里
Read more on sessions from the PHP Manual. Here
注意:另外请记住,如果您使用会话变量,则需要在每个页面上调用 session_start();
.
Note : Also keep in mind, you need to call session_start();
on each and every page if you are making use of session variables.
这篇关于我到底应该把 SESSION_START 放在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!