我在我的网络应用程序中遇到问题,我使用codeigniter 2.2.6,当我在localhost中运行时,应用程序工作应用程序工作正常,但当我上传到网络托管时,无法设置会话user_data。任何人都可以帮助和讨论我的问题?感谢
<?php
已定义('BASEPATH')或退出('不允许直接访问脚本');
类Login扩展了CI_Controller {
function __construct(){
parent::__construct();
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->library('session');
}
public function index(){
if ($this->session->userdata('site_lang')=="") {
$this->session->set_userdata('site_lang','english');
}
$this->form_validation->set_rules('username_login', 'Username', 'required');
$this->form_validation->set_rules('password_login', 'Password', 'required');
if ($this->form_validation->run()){
//my code !
$m_url = URL_API;
$function = "login_user";
$username_login = $this->input->post('username_login');
$password_login = $this->input->post('password_login');
$url = $m_url . "/" . $function . "?" ."u=". $username_login . "&" ."p=". md5($password_login);
$json_data = file_get_contents($url);
$data = json_decode($json_data);
$status = $data->status;
if ($data->status == "000"){
$login= array (
'session_username_login' => $data->username,
'session_customer_id' => $data->customer_id,
'session_customer_no' => $data->customer_no,
'session_customer_name' => $data->customer_name,
'session_customer_email' => $data->customer_email,
'session_customer_gender' => $data->customer_gender,
'session_customer_status' => $data->customer_status,
'session_customer_handphone' => $data->customer_handphone,
'session_customer_birthday' => $data->customer_birthday,
'session_customer_address' => $data->customer_address,
'session_password_login' => md5($password_login) );
$this->session->set_userdata($login);
$_SESSION['session_username_login'] = $data->username;
}
elseif ($status == "007") {
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">'.lang('username_password_wrong').'</div>');
redirect(MENU_LOGIN);
}
elseif ($status == "005") {
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">'.lang('password_wrong').'</div>');
redirect(MENU_LOGIN);
}
elseif ($status == "004") {
$this->session->set_flashdata('msg','<div class="alert alert-danger text-center">'.lang('username_wrong').'</div>');
redirect(MENU_LOGIN);
}
}
if($this->session->userdata('session_password_login') != null){
redirect(MENU_MARKETPLACE);
exit;
}
}
$this->load->view(MENU_LOGIN);
}
}