$ _ Cookie usage

Source: Internet
Author: User

Set and send cookies:

<? PHP $ value = "my cookie value"; // send a simple cookiesetcookie("TestCookie",$value);?> <HTML> <body> ......
<? PHP $ value = "my cookie value"; // send a cookie that expires in 24 hourssetcookie("TestCookie",$value, time()+3600*24);?> <HTML> <body> ......
Example 2

Different Methods for retrieving cookie values:

<HTML> <body> <? PHP // output individual cookieecho $ _ cookie ["testcookie"]; echo "<br/>"; echo $ http_cookie_vars ["testcookie"]; echo "<br/>"; // output all cookieprint_r ($ _ cookie);?> </Body> 

Output:

my cookie valuemy cookie valueArray ([TestCookie] => my cookie value)
Example 3

Delete a cookie by setting the expiration date to the past date/time:

<? PHP // set the expiration date to one hour agosetcookie ("TestCookie", "", time() - 3600);?> <HTML> <body> ......
Example 4

Create an array COOKIE:

<? PHPsetcookie("cookie[three]","cookiethree");setcookie("cookie[two]","cookietwo");setcookie("cookie[one]","cookieone");// Output cookie (after the page is reloaded) if (isset ($ _ cookie ["cookie"]) {foreach ($ _ cookie ["cookie"] as $ name = >$ value) {echo "$ name: $ value <br/>" ;}}?> <HTML> <body> ......

Output:

three : cookiethreetwo : cookietwoone : cookieone

 

 

$ _ Files get the Upload File Information egg size absolute path name

A constant is a value that cannot be modified in a program.

The define () function assigns a variable a constant. Egg define ("ABC", 123); the following code uses ABC to represent 123.

\ N escape character line feed

 

$ _ Cookie usage

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.