How does php determine that the user has logged on?

Source: Internet
Author: User
How does php determine that a user has logged on to a website recently and has encountered a problem after login registration? How does it know whether the user has logged on to the website? Do I need to add fields to the database for configuration? In addition, how can I configure the site configuration? for example, if I want to create a configuration file to write the public information of the site, such as the root directory path of the site, how should I write this? Thank you for your advice!


Reply to discussion (solution)

Use? Login ?, Use? Id and other information? Incoming session
? Face judgment? Does the session exist ,?? Use? Whether you have logged in.

??? Surface

Session_start (); // used? After login is successful, $ _ SESSION ['uid'] = 1 ;//?? Fill in? Id


Sentence ?? Surface
Session_start (); if (isset ($ _ SESSION ['uid']) & $ _ SESSION ['uid']> 0) {echo? Logged on ';} used by else {echo? Not logged on ';}

Oh, that's it. you can try it. thank you! What are the advantages of global settings?

It seems that the current website uses cookies and memcache for user login verification. if you try Baidu Sina or something, you will not be able to log on if you try to disable cookies.

The session can solve this problem.

Oh, that's it. you can try it. thank you! What are the advantages of global settings?


Global. you can save the value as a constant.
Define ("NAME", "XX ");
Implement value transfer, which can be saved through session and cookie and can be obtained anywhere.


Oh, that's it. you can try it. thank you! What are the advantages of global settings?


Global. you can save the value as a constant.
Define ("NAME", "XX ");
Implement value transfer, which can be saved through session and cookie and can be obtained anywhere.


In fact, I want to understand how the global configuration of the website is implemented? Also, after the configuration file is configured, do I have to make every referenced file use the configuration information in it ???

The first floor has been answered and uses cookies or sessions to remember them.

I found many new users added to the CSDN PHP Forum ~ ~ PHP talents

Generally, session is used to solve the problem of logon.
Cookie can be used to store user information into the user's computer for the next login convenience.

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.