PHP4 cookie support detailed transfer from house Orso near _php tutorial

Source: Internet
Author: User
PHP4 Cookies Support detailed establishment of commercial sites or more sophisticated personal sites, often need to record visitors ' information, in PHP provides two convenient means: Session and Cookie function. In order to permanently maintain user information, Cookies are the most convenient means. Here I will give you a detailed explanation of the function of the cookie and how to use it. One: Cookies must be set before cookies are set to use cookies. function prototypes: int Setcookie (string name,string value,int expire,string path,string domain,int Secure) where, except for name, all parameters are optional, You can use an empty string to indicate that it is not set. Property value: Used to specify a value. Property path: Used to specify which directory path the cookie is sent to the server. Attribute domain: Ability to limit the sending of cookies on the browser side. Expire parameter: Used to specify the effective time of the cookie, which is a standard Unix time stamp. You can use the time () or the mktime () function to obtain the unit in seconds. Secure parameter: Indicates whether this cookie is transmitted over the network via an encrypted HTTPS protocol. Two: Precautions when setting cookies the cookie is set on the same page, in fact, in the order from the back to the next. If you want to delete a cookie before writing to a cookie, you must write the statement and then write the DELETE statement. Otherwise an error will occur. Three: setcookie example simple: Setcookie ("MyCookie", "Value_of_mycookie"); With Expiration: Setcookie ("Withexpire", "Expire_in_1_hour", Time () +3600); Everything: Setcookie ("Fullcookie", "Full_cookie_value", time+3600, "/forum", "www.123.com", 1); Four: Some characteristics of cookies cookies are path-oriented. When the default Path property is passed, the Web server page automatically passes the current path to the browser. Specifying a path forces the server to use the path of the setting. Cookies placed on one directory page are not visible on the page of another directory. V: Receive and process cookies the processing of cookies is fully automated, as is the principle of processing form variables. Of course, you can also use PHP global variables, $HTTP _cookAn array of ie_vars. Example: Echo $mycookie; echo $cookie array[0]; echo Count ($cookie Array); echo $HTTP _cookie_vars["MyCookie"]; VI: Delete Cookie (1) Call Setcookie () with the name parameter only; (2) to make the expiry time () or time-1; VII: Restrictions on the use of cookies (1) must be set before the content output of the HTML file; (2) Different browser to the cookie processing inconsistent, must be considered when using; (3) client-side restrictions, such as user settings prohibit cookies, the cookie can not be established; Eight: A specific example, I hope you have a more profound understanding of cookies How about, through the above introduction, you do not have a detailed understanding of the cookie function in PHP. Use your intelligence to make your site more powerful. Please contact fbigov@sina.com If you have any questions. Let's make progress together.

http://www.bkjia.com/PHPjc/532234.html www.bkjia.com true http://www.bkjia.com/PHPjc/532234.html techarticle PHP4 Cookies Support detailed establishment of commercial sites or more sophisticated personal sites, often need to record visitors ' information, in PHP provides two convenient means: session and COO ...

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