The site is the session to keep in touch, I manually deleted all the cookies on the client, why is it still logged in when I visit again?

Source: Internet
Author: User
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!

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.