PHP's understanding of cookies and session

Source: Internet
Author: User
PHP's understanding of the cookie and session

For the understanding of cookies:
A cookie is a way that the server leaves the client with a gift (a small dessert) to complete the server's authentication to the user.
Specifically, when the user logs on to the server, there is a server through the Setcookie function in the client's browser
There are some data (user name, password, login or not) that can be identified. Wait until the same user accesses the site

Other pages, the server will determine whether the same user behaves according to the data.

In addition to the use of cookies when a key function Setcookie (); So the application of cookies is quite simple.


For the session Understanding:

The first explanation is that the session is a verification method to keep personal information on the server side, but there is a means to connect with the client

, so there are two different conversational approaches based on cookies and URLs.

Session_Start ()

SESSION_ID ()

$_session

The role of these numbers is fully understood.
The value of session_id () is generated when the session_start () is executed, otherwise the echo session is output ();
In addition, the values created at this time are $_session, such as $_session["name"]= "Zhangsan"; $_session["age"]=23;
These values will be together with session_id (), like members in a group.
When jumping to another interface, the first step is to execute session_start ().
At this point the system will determine whether there is an existing session_id, if there is and the same as the previous one, so good, the current $_session
The values inside the array are still members of the original group. Idea if the system didn't find session_id, then I'm sorry, I have to create another
session_id But this is the other group, with the original session_id or $_session has no relationship, according to this idea
Understanding a cookie or URL-based session will make you understand ^_^ | |

I would like to recommend an article to you to help understand the http://www.jz123.cn/text/196.html

  • 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.