Reputation: 13
I have a problem with a session in CodeIgniter, I want to make as a session with token. But there is an error as follows
Fatal error : Call to undefined method CI_Session::set_token()
function __construct()
{
parent::__construct();
$this->load->model('appdata','mod');
$this->load->library('session');
}
public function token($id_user)
{
$token="";
$date_key = date("Y-m-d h:i:s",time());
$random_key = rand(1,0);
$usertoken = substr($id_user,2,4);
$token = $date_key."-".$usertoken."-".$random_key;
$this->session->set_token('key_token',$token);
session_start();
return $token;
}
please help me , thank you
Upvotes: 1
Views: 100
Reputation: 4922
it's not set_token it's set_userdata
public function token($id_user)
{
$token="";
$date_key = date("Y-m-d h:i:s",time());
$random_key = rand(1,0);
$usertoken = substr($id_user,2,4);
$token = $date_key."-".$usertoken."-".$random_key;
$this->session->set_userdata('key_token',$token);
session_start();
return $token;
}
Upvotes: 1