[eluser]asmaa kamal[/eluser]
this is my code
i want to put cookies to save email,password in user computer
is this way which i used in my code is true or not?
Code:
<?php
class Main extends CI_Controller {
function Main()
{
parent::__construct();
$this->load->model('user_model');
$this->load->library('form_validation');
$this->load->helper('cookie');
}
public function login()
{ //echo current_url();
$this->form_validation->set_rules('userEmail','email','trim|required|valid_email|callback_check_login');
$this->form_validation->set_rules('userPassword','password','trim|required|md5');
if($this->form_validation->run()==TRUE)
{
if($this->user_model->Login(array('userEmail'=>$this->input->post('userEmail'),'userPassword'=>$this->input->post('userPassword'))))
{ redirect('main/login');
}
else
{
if (!get_cookie('unique_cookie')) {
// cookie not set, first visit
// create cookie to avoid hitting this case again
$cookie = array(
'name' => 'unique_cookie',
'value' => 'The Value',
'expire' => time()+86500,
'domain' => '.some-domain.com',
'path' => '/',
'prefix' => '',
);
$this->input->set_cookie($cookie);
}
redirect('dashboard');
}}
/* echo ' not sucess' ;*/
$this->load->view('main/login_form'); }
function index()
{
$this->load->view('main/main_index');
}
function check_login($userEmail)
{
if ($this->input->post('userPassword'))
{
$user=$this->user_model->GetUsers(array('userEmail'=>$userEmail,'userPassword'=>$this->input->post('userPassword')));
if($user) return true ;
else
{$this->form_validation->set_message('check_login','your useremail/password is invalid.');
return false;
}
}
}
}
?>
i read userguide _ cookie helper but i dont know is this way in my code is true or not
How do I know is the cookies set or not ?