12th Chapter Session Control _php Tutorial

Source: Internet
Author: User
Tags set cookie
Learning Essentials:
Application of 1.Cookie
2.Session Session Processing

HTTP (Hypertext Transfer Protocol) defines the transmission of text, graphics, video, and all data through the World Wide Web (WWW)
All the other data rules. HTTP is a stateless protocol that states that each request is processed in relation to the previous or subsequent
The request is irrelevant. While this simplified implementation has made a great contribution to the popularity of HTTP, it is a great choice to create complex
This is a bit disturbing for developers of WEB applications. To solve this problem, there is a
A small amount of information (cookie) is stored on the machine.
Due to the size limit, number of cookies and other reasons, the developer proposed a solution: session
The word processing.

A Application of Cookies

Set Cookie: Thesetcookie() function can generate a cookie file on the client, which can be saved to
Time, name, value, and so on.


Create a cookie

 
  < span="">(' name ', ' Lee ',< span="">() + (7*24*60*60< span="">?>

Parameter 1:cookie name
Parameter 2:cookie value
Parameter 3:cookie Expiration time

Read cookies

 
  < span="">< span="">[' Name '< span="">?>

Delete Cookies

 
  < span="">(' name '< span="">< span="">, ' (' Name ', ' Lee '< span="">, ()-1  < span=""> ?>

Restrictions on the use of cookies

1, the HTML file must be set before the content output;
2. Different browsers have inconsistent handling of cookies and sometimes have incorrect results.
3, the limit is on the client. The maximum number of cookies a browser can create is 30, and each cannot
Over 4KB, the total number of cookies that can be set per Web site cannot exceed 20.

Two Session processing

When using session sessions, you must start the session and start with Session_Start ().

Create session and read session

 
  < span="">< span="">< span="">[' name '] = ' Lee '< span="">< span="">< span="">[' name '< span="">?>

Determine if the session exists

 
  < span="">< span="">< span="">[' name '] = ' Lee '  < span="">    < span="">  (< span="">< span="">[' Name< span="">'< span="">< span="">[' name '?>< span="">

Delete session

 
  < span="">< span="">< span="">[' name '] = ' Lee '< span="">< span="">(< span="">[' name '  < span=""> < span=""> < span="">[' name '?>  < span=""> 

Destroy All session

 
  < span="">< span="">< span="">[' name '] = ' lee '< span="">< span="">[' name2 '] = ' lee '  < span="">  < span="">  < span=""> [' name '  < span="">  < span="">  < span="">  [' < span="">name2 '?> < span="">  < span="">

Note: The article is from Eon to PHP video tutorial, this article is limited to exchange use, not for commercial purposes, otherwise the consequences.

http://www.bkjia.com/PHPjc/759627.html www.bkjia.com true http://www.bkjia.com/PHPjc/759627.html techarticle Learning Essentials: 1.Cookie Application 2.Session Session processing HTTP (Hypertext Transfer Protocol) defines all of the text, graphics, video, and all other data transmitted over the World Wide Web (WWW) ...

  • Related Article

    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.