dongyi6845 2011-11-20 19:20
浏览 27
已采纳

在Internet Explorer中设置cookie的麻烦

this is a section of my script:

session_start();
echo '<p>Initiated...';
if (isset($_POST['submit'])) {
    echo '<p>Executed...';
if ($_POST['username'] == $un && $pw == md5($_POST['password'])) {

    $_SESSION['user'] = 'admin';
    echo '<p>Success...';



$value = 'admin';

setcookie("user2", $value);
setcookie("user2", $value, time()+36000);  /* expire in 1000 hours */
setcookie("user2", $value, time()+36000, "/", "my.domain.net", 1);

echo 'Hello!'.$_COOKIE["user2"];
echo $HTTP_COOKIE_VARS["user2"];
}
}

It works perfectly in FireFox, Chrome and Safari, however it will not work in Internet Explorer as it does not seem to be setting cookies. The output in Internet Explorer is:

Initiated...

Executed...

Success...Hello!

In Chrome/Safari/FireFox:

Initiated...

Executed...

Success...Hello!admin

Settings in Internet Explorer are set to accept all cookies .. I'm really stuck on this. :( please help.

  • 写回答

1条回答 默认 最新

  • douci7521 2011-11-20 19:22
    关注

    Try adding the following after the session_start()

    header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题