Cookis settings, read method, cross-domain [second-level domain name]

Source: Internet
Author: User
Tags php tutorial setcookie

Cookis settings, read method, cross-domain [second-level domain name]
$ Time = 30;
$ Domain = '.111cn.net ';
Setcookie ("abcde", "aaaaaa"); // The simplest cookie setting method

Setcookie ('load', 'www .111cn.net ', time () + 3600*24,'/',' .111cn.net '); // second-level domain names can be set here
$ Cookis = $ _ COOKIE ['loaddomain ']; // read the domain name
Print_r ($ cookis );
/*

Here are several examples:

Simple:

SetCookie ("MyCookie", "Value of MyCookie ");

With expiration time:

SetCookie ("WithExpire", "Expire in 1 hour", time () + 3600); // 3600 seconds = 1 hour

Everything:

SetCookie ("FullCookie", "Full cookie value", time () + 3600, "/forum", ".111cn.net", 1 );
*/


?>

<Script language = "javascript tutorial">
Function setcookie (name, days)
{
Var url = document. domain;
Var exp = new Date ();
Exp. setTime (exp. getTime () + days x 24x60*60*1000 );
Document. cookie = name + "=" + escape (url) + "; expires =" + exp. toGMTString ();
 
}

Function getcookie (name)
{
Var arr = document. cookie. match (new RegExp ("[sS] *" + name + "= ([^;] *)");
Alert (arr );
If (arr! = Null)
Return unescape (arr [1]);
Return null;
}
</Script>
// Php Tutorial cookies

// Asp tutorial cookies

Response. Cookies ("Uto") ("UtorName") = UtorName
Response. Cookies ("Uto") ("UtorPwd") = UtorPwd
Response. Cookies ("Uto"). Domain = "utoper.com"
Response. Cookies ("Uto"). Secure = False

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.