I just touch php less than 3 months, noob a ... Try to write the site is to keep in touch with the session, without closing the browser, I manually delete all the cookie files on the client, and then refresh the site, found that the account is logged in the status ... What's going on here?
And according to some of the sites I usually use, as long as the cookie is emptied, the login status will be exited ...
Below is the younger brother's problem code, please Daniel is not hesitate to enlighten.
Page A that processes the login code
//登录成功,保持登录状态function login_true($username){ session_start(); $_SESSION['userinfo']=array('uid'=>476283675,'username'=>$username);}
Page b showing the login interface
/*如果$_SESSION['userinfo']或$_SESSION['userinfo']['uid']为空 *则说明未登录,引导用户登录 */session_start();if (empty($_SESSION['userinfo'])or empty($_SESSION['userinfo']['uid'])){ echo "点我登录"; die('请先登录');}echo '晚上好';
After emptying the cookie file, or remain logged in, where is the problem?
Reply content:
I just touch php less than 3 months, noob a ... Try to write the site is to keep in touch with the session, without closing the browser, I manually delete all the cookie files on the client, and then refresh the site, found that the account is logged in the status ... What's going on here?
And according to some of the sites I usually use, as long as the cookie is emptied, the login status will be exited ...
Below is the younger brother's problem code, please Daniel is not hesitate to enlighten.
Page A that processes the login code
//登录成功,保持登录状态function login_true($username){ session_start(); $_SESSION['userinfo']=array('uid'=>476283675,'username'=>$username);}
Page b showing the login interface
/*如果$_SESSION['userinfo']或$_SESSION['userinfo']['uid']为空 *则说明未登录,引导用户登录 */session_start();if (empty($_SESSION['userinfo'])or empty($_SESSION['userinfo']['uid'])){ echo "点我登录"; die('请先登录');}echo '晚上好';
After emptying the cookie file, or remain logged in, where is the problem?
Use the browser's own purge button.
Supposedly, the cookie has been successfully cleared, the cookie storage SessionID is gone, request to the backend session mechanism can not obtain the SessionID to the corresponding session file to obtain information. I don't know what ring you're dealing with. Cookie not cleared? SessionID has other forms taken to the request body?
The session is passed a session_id value at each request to save the conversation, and there are two ways to pass it, one is to carry the cookie through each request, or one is passed through a URL, if you PHP is set by a cookie, So as long as the original cookie is deleted under the corresponding domain name, the server will automatically generate a new session_id, that is, lost the original session, as for your problem, I think it is the wrong way to delete, since it is a developer, then use the browser's open tools, The above can display all cookies under the current domain name, or delete cookies, and the browser recommends chrome!