dongmeixi5311 2012-11-21 17:17
浏览 123

为什么没有在此功能中设置登录和会话ID?

I am try to loggin in and setting the session id.Below code did not authenticate the login successfully and did not set the session id.Plz help.

  public $userid;

  function login()
    {
        $pwdHasher = new PasswordHash(8, FALSE);

        if(isset($_POST['logging'])  AND  !empty($_POST['logging'])){


            $email=mysqli_real_escape_string($this->db->connection ,$_POST['email']);
            $pass=mysqli_real_escape_string($this->db->connection ,$_POST['pass']);
            $sql=mysqli_query($this->db->connection,"SELECT * FROM user where email='$email' AND password='$pass'");
            $numrows=mysqli_num_rows($sql);
            $resid=mysqli_fetch_array($sql);
            $checked = $pwdHasher->CheckPassword($pass,$numrows);
            if($checked){
                $this->userid=$_SESSION['id']=$resid['id'];

                $this->login=TRUE;


                echo "u r logedin.Plz click here to go  to main area<a href='main.php'>main</a>";
            }
            else{
                echo "username r password is wrong";
                $this->login=FALSE;
            }
        }
    }
  • 写回答

2条回答 默认 最新

  • dongyan9838 2012-11-21 17:22
    关注

    You need to start a session with session_start() before using the $_SESSION array

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 目详情-五一模拟赛详情页
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b