Codeigniter登录在IE中不起作用,但只能使用Mozilla

时间:2014-10-05 18:04:42

标签: php ajax

我在Codeigniter中遇到登录问题。它在IE中不起作用。我在php控制器中发送一个ajax请求。它在Mozilla中工作,但在IE和其他浏览器中不起作用。我调试更多时间。因此,当我尝试在IE中登录即时会话销毁但是捕获会话Mozilla时我得到了。 这是我的javascript代码:

function check_login () {
var flag=true;
var user_name=$('body').find('#user_name').val();
var user_password=$('body').find('#user_password').val();

    if(user_name==''){
    $('#username_login_msg').html('Email  required.');
        flag=false;
    }else{
        $('#username_login_msg').html('');
   }
    if(user_password==''){
    $('#password_login_msg').html('Password required.');
    flag=false;
   }else{
    $('#password_login_msg').html('');
  }

       if(flag==true){
    //alert(user_name);
        /*$.post("http://luxhometour.com/user/login",{ 'username': user_name,    
'user_password': user_password}, function(data, textStatus, xhr) {

            if(data=='ok'){
                   //window.location='user/dashboard';
                   window.location.replace('http://luxhometour.com/user/dashboard');
            }else{
                $('#main_login_msg').html(data);
            }
           });*/
           $.ajax({
                url:"http://www.luxhometour.com/user/login",
                type:"POST",
                data:{ 'username': user_name, 'user_password': user_password},
                success:function(data) {
                alert(data);
                if(data=='ok'){
                  //window.location='user/dashboard';
                //window.location.href='http://luxhometour.com/user/dashboard';
              }else{
                  $('#main_login_msg').html(data);
            }
                }
            });

      }

  return false;
}

这是我的php代码:

public function login(){

        if(user_logged_in()){
          redirect('user/dashboard');
      }

      if($_POST){

      $username=trim($this->input->post('username'));

      if(!filter_var($username, FILTER_VALIDATE_EMAIL))
        $user_data['username']=$username;
      else
        $user_data['email']=$username;
        $user_data['password']=sha1(trim($this->input->post('user_password')));
        $user_data['user_role']=2;
        $user_data['user_status']=1;
        $login2_status= $this->user_model->login2($user_data);
         if($login2_status==0){
            echo "Try again, Incorrect email or password.";
          }
          if($login2_status==1){
               //print_r($this->session->all_userdata());
              echo "ok";
           }
           if($login2_status==2){
            echo "Your account not activated now till.";
          }

    }else{
      echo "Try again, Incorrect email or password.";
    }
}

这是我在config.php文件中的会话配置

$config['sess_cookie_name']     = 'ci_session';
$config['sess_expiration']      = 30*60;
$config['sess_encrypt_cookie']  = FALSE;
$config['sess_use_database']    = FALSE;
$config['sess_table_name']      = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

1 个答案:

答案 0 :(得分:0)

认为你需要在这一行添加引号

     data: "{'username': "+user_name+", 'user_password': "+user_password+"}",