Questions about using a cookie under a domain name under level two domain _javascript tips

Source: Internet
Author: User
If we want to use a cookie under Www.jb51.net, just set a cookie in the file below this station.
But what if we want to implement cookies that are set in a first-level domain, and use it under a level two domain?

For example: We in the first level domain name is a website such as: Www.jb51.net, he below has a level two domain name like: bbs.jb51.net
We want to achieve in the first level domain name after login, keep this cookie to level two domain name, that is, achieve the effect of synchronous login,
So how do we set this cookie?? It's actually very simple.

Take just that domain name (www.jb51.net), we can set the Cookie:setcookie ("Fangbinbin", "Mengfei", Time () +3600, "/", "jb51.net");

Then we can use directly under this www.jb51.net and Bbs.jb51.net (Echo $_cookie[' Fangbinbin ';) to output the value of the COOKIE set.

This way to solve 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.