Cookie-han shunping

Source: Internet
Author: User

1. php calls the system time in PHP. set the Default Time Zone in ini: Find data. timezone = remove the; sign before it, and then set data. timezone = "Asia/Shanghai.

Call method: date ("Y-m-d h: I: s") automatically returns a system time string.

2. Insert the PHP code in HTML:

Automatically enter the username :______

<HTML> <? Phprequire_once 'common. php';?> <Form action = "loginprocess. php" method = "Post"> Username: <type = "text" name = "name" value = "<? PHP echo getcookieval ("ID") ;?> "/> </Form> 
<?php    function getCookieVal($key){        if(!empty($_COOKIE($key))){               return $_COOKIE($key);        }else{               return "";         }       }    ?>  

3. The cookie stores the key-value pair and the duration of the key-value pair. $ Key => $ Val

You can use setcookie to set, modify, and delete existing key-value pairs;

Use $ _ cookie [''] to obtain the cookie;

Empty ($ _ cookie ['']) is used to determine whether a corresponding key-Value Pair exists.

4. Cookies are stored on the browser client. When the browser wants to access an address, it sends an HTTP request to the server, and then the server sends the PHP page back to the browser. When the browser enters certain information such as the user name and password on the PHP page, PHP will save the information in cookie form on the client. When the browser accesses the page again, the cookie is sent to the server when an HTTP request is sent, and the server displays the specific cookie information that was originally saved.

Defect: Cookie transmission consumes a certain amount of bandwidth, and security issues exist (username, password, and other information is continuously transmitted over the Internet)

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.