[eluser]Unknown[/eluser]
hy all, I am still newbie in using codeigniter framework, I get a problem when I am using setcookie function in codeigniter
in this function I use setcookie but it does not work, I mean the cookie return "bool(false)" not return the value that put in the cookie
Code:
function login_verivication1(){
//load form validation library
$this->load->library('form_validation');
//validation rule "field/input name", "Message that what fiel is wrong", "rule"
$this->form_validation->set_rules('usrname', 'User Name', 'trim|required');
$this->form_validation->set_rules('pass', 'Password ', 'trim|required');
if ($this->form_validation->run()== FALSE){
$data['error'] = '';
$this->load->view('login_view',$data);// if validation false go back to login page and show error
} else {
$this->load->model('login_model');//load model that consist function for login
$query = $this->login_model->login_verivication();//load verivication function from model will return true if username and password macth
if ($query == true){
$database= $this->login_model->login_update('FREDY PRANAJAYA');// update LAST_LOGIN,SESSION,IP_LOGIN
// print_r($user);
$data = array (
'name' => $database['name'],
'id' => $database['id'],
'login_ok' => true
);
$this->session->set_userdata($data);
//setcookie('loginok',$database['id']);
setcookie('login',6);
redirect('student','refresh');
}else {
$data['error'] = "Your User Name or Password doesn't Macth. Try again";
$this->load->view('login_view', $data);
}
}
}
but when I try like this, it work properly,
Code:
public function index()
{
setcookie('login',8);
redirect('student');
}
I don't know whats wrong with this, can anyone suggest solution for this? I appreciate every help and suggestion. thank you