PHP cookie usage and cross-origin instance tutorial-PHP source code

Source: Internet
Author: User
Ec (2); * & nbsp; Syntax: & nbsp; setcookie (name, value, expire, path, domain, secure) & nbsp; name, cookie name required & nbsp; value, cookie value, required & nbsp; other writeable, however, this function is provided in the following example: time () + 3600*24 & nbsp script ec (2); script

/*
Syntax:
Setcookie (name, value, expire, path, domain, secure)
Name, cookie name required
Value, cookie value, required

Others can be written, but this is a function.
Expire expiration time, for example: time () + 3600*24
Path, for example,/root directory, you can also specify a level-2 directory, for example,/111cn.net/
Domain name, this is the second-level domain name is to be noted, if you let all the second-level domain can access this cookie, It is set like this: ".111cn.net", then, s.111cn.net, down.111cn.net can all access this cookie.
Secure is generally 1

Next, let's look at a cookie instance,
*/
$ Value = 'www .111cn.net ';
Setcookie ('loaddomain ', $ value, time () + 3600*24,'/',' .111cn.net '); // set cookis

// The value of the following cookie is read. in php, the $ _ COOKIE with the cookie name is OK. As follows.
If (isset ($ _ COOKIE ['loaddomain '])
{
$ Cookis = $ _ COOKIE ['loaddomain '];
Header ("location: $ cookis ");
}

// Source www.111cn.net

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.