Implement user Login function with cookie and session

Source: Internet
Author: User

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

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.