How to insert login date and time in db using codeigniter?

This is my model code

class front_model extends CI_Model {
	public function login(){
		$result = $this->db->get('auth_user');
		if($result->num_rows() > 0){
			$result = $result->row();
			$data = array(
				'id'		=> $result->id,
				'username'	=> $result->username,
			return true;
			return false;

Hi @pkpathak1994 and welcome to the forums.

Check out PhpMyAdmin and the fields setting. A column can be set that inserts a timestamp whenever the record is updated.

table_name = auth_user
column = last_login
data_type = datetime

Try this:

Just one click to change the field attribute to ‘ON_UPDATE_SET_CURRENTTIMESTAMP‘


1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.