我想从同一个域的iframe应用中获取CI SESSION 我在CI和会话上的代码正在运行
public function ceklogin()
{
if(isset($_POST['login'])){
$user = $this->input->post('user',true);
$pass = $this->input->post('pass',true);
$cek = $this->web->proseslogin($user,$pass);
$hasil = count($cek);
if ($hasil > 0){
$pelogin = $this->db->get_where('tb_user',array('username' => $user,'password' => $pass))->row();
$level = $pelogin->level;
$data= array ('level' => $level,
'logged_in'=> true,
'user_id'=>$pelogin->id,
'namanya'=>$pelogin->nama_lengkap,
'levelnya'=>$pelogin->level,
'kec_id_user'=>$pelogin->kec_id_user);
$this->session->set_userdata($data);
$this->input->set_cookie("idckec","kec_id_user"); //test set cookies
$_SESSION['idkec'] = "kec_id_user"; //test set manual session
if($pelogin->level == 'Admin'){
redirect('index.php/dashboard');
}elseif($pelogin->level == 'User'){
redirect('index.php/dashboard?m='.$_SESSION[idkec]);
}elseif($pelogin->level == 'Lain-lain'){
redirect('lain-lain');
}
$this->session->set_flashdata('benar', 'login berhasil');
//redirect('dashboard');
}else{
$this->session->set_flashdata('salah', 'Username dan Password tidak valid, coba ulangi!!!');
redirect('index.php/admin','refresh');
}
在iframe中,我想获得CI会话
session_start();
echo $_SESSION["idkec"]; //Notice: Undefined index: idkec in ...
echo $_COOKIE["idckec"]; //Notice: Undefined index: idckec in....
我如何获得CI课程? 谢谢
非常感谢
答案 0 :(得分:0)
设置:
//$_SESSION['idkec'] = "kec_id_user"; //test set manual session
$this->session->set_userdata('idkec', 'something');
获取:
//session_start(); // don't do this
echo $this->session->userdata('idkec');
更多:
https://www.codeigniter.com/user_guide/libraries/sessions.html