Home > Backend Development > PHP Tutorial > 在线等php跨域能取得客户端COOKIES吗,写了几句话都倒处报错,实在是受不了了。求助!

在线等php跨域能取得客户端COOKIES吗,写了几句话都倒处报错,实在是受不了了。求助!

WBOY
Release: 2016-06-23 14:24:53
Original
905 people have browsed it

做了一个测试的例子,结果到处是错,而且偶根本看不出来哪里有错,求助。
http://www.test1.com/test.htm
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">





<script></script>



http://www.test2.com/下面有两个文件

test.js
document.write("<script></script>");

test.php
//print_r($_COOKIE);
echo "<script>alert('test');</script>";
?> 

直接输入http://www.test2.com/test.php没有错误
但是输入http://www.test1.com/test.htm报语错误。

一来是想测试下
setcookie("TestCookie",$value);
$_COOKIE["TestCookie"];
结果直接不能运行,求助,实在逼得没有办法了。谢谢大家!

回复讨论(解决方案)

document.write(""."ipt>");

用 js 写的 script 标记必须切断,否则会当做 script 标记处理,当然也就出错了

按版主的改了,
document.write(""."ipt>");

提示缺少标识符
晕死,哪里的问题,谢谢大家帮忙!

你没有理解COOKIE的本质啊,亲!

噢,写错了,应该是
document.write("" +"ipt>");

跨域用jsonp

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