简体   繁体   English

我如何获取id和ip_address并在Codeigniter的ci_session表中添加一列user_id并添加一

[英]How can I get the id and ip_address and add one more column user_id in ci_session table in Codeigniter and add one

  1. how can I get the id (session id) from ci_session table 如何从ci_session表中获取ID(会话ID)
  2. I added user_id field in ci_session table but I do not know how can I set and get this field 我在ci_session表中添加了user_id字段,但我不知道如何设置和获取此字段
  1. You could use the $this->session->session_id to get the session id. 您可以使用$this->session->session_id来获取会话ID。
  2. You could use $this->session->set_userdata('user_id','value'); 您可以使用$this->session->set_userdata('user_id','value'); to save value into user_id column, and $this->session->userdata('user_id'); value保存到user_id列和$this->session->userdata('user_id'); to retrieve that value . 检索该value

Edit 编辑

If you still want to update the table column, you could using the old way : 如果仍然要更新表列,则可以使用旧方法:

$this->db->where('id', session_id());
$this->db->update($this->config->item('sess_save_path'), array('user_id'=>'1111'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM