duanchao5258 2012-08-07 20:58
浏览 81
已采纳

Cookie无法在不同的浏览器中运行

I finally got my code working for a password protect script. It's still in its infancy, so I understand it isn't secure. My problem is that I seem to have problems across a number of different computers and browsers. From what I've seen, firefox has no problem with the cookies being set. I'm running into trouble on certain machines not setting cookies.

What I've seen is that on one machine, I have a system with ie, chrome, and firefox. The cookies don't work on chrome, but work with ie and firefox. On my linux machine, firefox works without a hitch. I don't have chrome installed on it so, I can't test that. Then on another machine, ie doesn't want to work with the website. I would think that it's a problem with the privacy settings, but it appears that they are all the same.

The odd thing about the chrome problem, is that I can see the cookie for the session, but I can't see the cookie that I set. So, obviously that is a problem, but I don't know why. I have the same problem with IE. I've set the IE machines to accept all cookies and have had no luck. The chrome browser is set to "Allow local data to be set".

Thanks in advance

      if (isset($_COOKIE["Cookie"])){
        FormatScreen();
      }
      else if ($_POST['access_password']){
        $PasswordEntered = crypt($_POST['access_password'],$salt);
        if ($PasswordEntered == $RealPassword){
            setcookie("Cookie", $PasswordEntered, time()+600, '/');
            FormatScreen();
        }
        else{
            echo LoginScreen();
        }
      }
  • 写回答

3条回答 默认 最新

  • dstbp22002 2012-08-07 23:38
    关注

    You should be using session cookies - look at http://www.w3schools.com/php/php_sessions.asp

    It will help improve security as the session is stored on the server and can't be tampered with. PHP then handles the session cookies on the client.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错