|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2017-1-22 20:51:04
|
显示全部楼层
Login.php 代码段:
- #判断用户状态
- if ($data['usersinfo']['status'] == 1) {
- #设置session,更新登陆时间,写日志,跳转到主页面
- $this->session->set_userdata('s_username',$username);
- $this->m_usermanage->update_lastlogintime($username);
- #写日志
- $this->logtodb->logdb(
- array(
- 'log_type'=>'0001',
- 'log_content'=>array(
- 'content'=>'用户成功登陆系统'
- )
- )
- );
- redirect('mainpage');
复制代码
logtodb类代码:
- <?php
- class Logtodb {
- protected $CI;
- public function __construct()
- {
- $this->CI =& get_instance();
- $this->CI->load->model('m_logtodb');
- $this->logdata['log_user']=$this->CI->session->userdata('s_username');
- }
-
- public function logdb($log_content) {
- $this->logdata['log_type']=$log_content['log_type'];
- $this->logdata['log_content']=serialize($log_content['log_content']);
- if ($this->CI->m_logtodb->wrlog($this->logdata)) {
- return TRUE;
- }else{
- return FALSE;
- }
- }
- }
- ?>
复制代码
在其他页面都没问题,就是在Login的时候取不到session |
|