Php--cookie

Source: Internet
Author: User

Create:

Using Setcookie (String $name [, String $value = "" [, int $expire = 0 [, String $path = "" [, String $domain = "" [, BOOL $se Cure = False [, bool $httponly = false]]] []]]) function creation,

Parameters Describe
Name Required, specify cookie name
Value Required, specify the value of the cookie
Expire Optional, to specify the validity period of the cookie
Path Optional, specify cookie server path
Domain Optional, specify the role of the cookie domain name
Secure Optional, specify whether to transfer cookies over HTTPS
HttpOnly Optional to specify whether cookies can only be accessed via the HTTP protocol (PHP5.2.0 join)

   When expire is not specified, the cookie is automatically cleared when the current session ends (browser close).

Setcookie ("TestCookie", "This was Test"); Setcookie ("TestCookie", "This is Test", Time () +3600); /* Valid for 1 hours * *

   

Setcookie after use, the Set-cookie information can be found in the HTTP request header.

  

Clear:

1. To delete a cookie, you need to ensure that it expires before triggering the browser's removal mechanism.

Use the Setcookie function to set the time to expire.

Setcookie ("TestCookie", "", Time ()-3600);

  

2. Set a null value for the cookie. ( This method is not recommended , the manual does not indicate this method, but in Linux under the EXT/STANDARD/HEAD.C section of the PHP source code, Php_setcookie () mentioned)

Setcookie ("TestCookie", "" "); Setcookie (" TestCookie ", NULL);

  

  

Php--cookie

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.