Questions about using cookies under a level-1 domain name under a level-2 Domain Name

Source: Internet
Author: User
Tags set cookie

For example, if we want to use a cookie under www.jb51.net, we only need to set a cookie in the file below this site.
But if we want to implement the cookie set under the first-level domain name and use it under the second-level domain name, what should we do?

For example, if a top-level domain name is a website such as www.jb51.net, there is a second-level domain name such as bbs.jb51.net.
We want to keep the cookie to the second-level domain name after logging on to the first-level domain name, that is, to achieve synchronous login,
So how do we set this cookie ?? It is actually very simple.

For the domain name www.jb51.net, we can set the cookie as follows: setcookie ("fangbinbin", "mengfei", time () + 3600 ,"/", "jb51.net ");

Then we can directly use (echo $ _ COOKIE ['fangbinbinbinbinbin'];) under www.jb51.net and bbs.jb51.net to output the set cookie value.

This solves the problem of synchronous login !!

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.