Because the webpage is a stateless connection program, you cannot know the user's browsing status, must record the user's information through the cookie or session.
Cookie: A mechanism for storing data on a remote browser to track and identify users. PHP transparently supports HTTP cookies. The cookies sent from the client are PHP5 included into the $_cookie global array.
Session:session is stored on the server (the session is stored by default as a file), the user's file is obtained according to the SessionID provided by the client, the value of the variable is acquired, session The ID can be transmitted to the server via the client's cookie or the additional data of the visitor's URL, and then the server reads the session directory.
Definition of the function:
Function name (formal parameter list)
{
function body;
return value;
}
All functions use the keyword function to start
Call to function:
Function name (actual argument list);
function has a return value:
Variable name = function name (actual argument list);
PHP Custom Functions
All functions use the keyword "function ()" to start
Named function-the name of the function should indicate its function. Function name begins with a letter or underscore
Add "{"-the section after the opening curly brace is the code of the function
inserting function code
Add a "}"-the function ends by closing the curly braces.
Implement user Login function with cookie and session