php跨域cookie共享使用方法_PHP

WBOY
Release: 2016-06-01 11:56:04
Original
954 people have browsed it

A 机器所在的域:a1.main.com,A 有应用 main.php
B 机器所在的域:b1.test.com,B 有应用 test.php

1.在 main.php 里设置 cookie 的时候, cookie 的设置方法如下:
复制代码 代码如下:
setcookie( "TestCookie",  "okol",  time() + 3600,  "/", "b1.test.com", 1 );

这样在 test.php 里就可以取到 cookie 。

2.输入 url 访问 test 的时候,必须输入域名才能解析。
比如输入: http://b1.test.com/test.php ,可以获取 cas 在客户端设置的 cookie ,
而 B 机器访问本机的应用,输入: http://localhost:8080/test.php 则不可以获得 cookie 。

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!