PHP Cookie&session Small Note

Source: Internet
Author: User
Tags change settings php session setcookie

PHP cookie&session, there is a need for friends can refer to the next.


**

Cookies

**
1. Create a cookie
Setcookie (Name,value,expire,path,domain); The Setcookie function must precede the label;
Eg:setcookie (User, "Zhuyumin", Time () +3600);
Meaning: Create a user cookie that is assigned a value of Zhuyumin, which expires after one hour.
2. Retrieving the value of a cookie
Cookieeg: _cookie["User"; Remove the value of the cookie user;
cookie;//Remove the value of all cookies. 3. Determine if Cookieisset has been set ( _cookie["user"));
4. Delete Cookies
Sets the expire of the cookie to the value of the past time.
Eg:setcookie ("User", "", Time ()-3600);

**

SESSION

*

The PHP session variable is used to store information about a user's session or to change settings for a user session. The Session variable holds information that is single-user and available to all pages in the application.
The Session works by creating a unique ID (UID) for each visitor and storing the variables based on this UID. The UID is stored in a cookie or through a URL.
Guide.
Start session: Session_Start (); used in front of the label;
Save Session:$_session ("");
Terminate session
Unset ();
The Session_destroy () function deletes all saved session data.

Cookies, PHP, 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.