iframe中的PHP Session问题

今天的工作中遇到了一个问题, 用iframe将一个php脚本嵌入另一个页面, 提交脚本表单后Session出了问题, 似乎无法保存(Firefox或Chrome无此问题, 仅在IE环境下有问题).

使用session_id()查看后发现, 在IE下iframe内容更新后Session ID会随之发生变化, 也就是说原有的Session不再生效了, 当前的Session是全新并空的.

搜索Google后得到解决办法, 在PHP脚本输出内容之前加入一行header, 如下

PHP
1
2
3
4
5
6
<?php
header('P3P: CP="CAO PSA OUR"'); //ADD IN THIS LINE IN ORDER TO SOLVE THE INTERNET EXPLORER ALWAYS GET NEW SESSION ISSUE
session_start();
$_SESSION['test'] = 'anything';
echo $_SESSION['test'];
?>

Comments (0)

› No comments yet.

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Pingbacks (0)

› No pingbacks yet.