Home > Web Front-end > JS Tutorial > body text

Regarding the use of COOKIE under the first-level domain name under the second-level domain name_javascript skills

WBOY
Release: 2016-05-16 17:59:29
Original
2375 people have browsed it

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, we must also set it in the second-level domain name. What should I do if it is used under a high-level domain name?

For example, if our first-level domain name is a website such as: www.jb51.net, and below it there is a second-level domain name such as: bbs.jb51.net
We want to achieve a After logging in to the first-level domain name, keep this cookie to the second-level domain name, that is, to achieve the effect of synchronous login.
So how do we set this cookie? It is actually very simple.

Take the domain name (www.jb51.net) just now, we can set cookies like this: setcookie("fangbinbin","mengfei",time() 3600,"/","jb51.net ");

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

This solves the problem of synchronous login! !

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!