并检测Codeigniter中的会话是否已过期

并检测Codeigniter中的会话是否已过期

本文介绍了自动过期会话,并检测Codeigniter中的会话是否已过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到很多关于我的主题的问题,但似乎我还没有找到我的答案。我实际寻找的是当会话过期时,用户将被自动重定向到一个页面您的会话已经过期。请注册以继续浏览。

I've seen plenty of questions here about my topic but it seems I still haven't found my answer. What I'm actually looking for is when the session expires the user will be automatically redirected to a page saying Your session has already expired. Please register to continue browsing..

实际上,我不知道如何确定用户的会话是否已过期。这是我到目前为止。

Actually I have no idea on how I could determine if the user's session has already expired. Here's what I have so far.

谢谢。

function trial() {

    $this->db->select()->from('user')->where('user_type', 'tester');
    $tester = $this->db->get();

    foreach ($tester->result() as $row) {

        $data = array(
            'id' => $row->id,
            'first_name' => $row->first_name,
            'last_name' => $row->last_name,
            'display_name' => $row->display_name,
            'email' => $row->email,
            'avatar' => $row->avatar,
            'user_type' => $row->user_type,
            'logged_in' => TRUE
        );
        $this->session->set_userdata($data);
    }

    redirect(base_url(), 'refresh');
}


推荐答案

对象和用户重定向任何页面,你可以检查会话对象已经存在,如果不存在你可以显示警报,会话已过期

you can store data in session object and user redirect any page , you can check session object already exist if not exist you can show alert, session is expired

这篇关于自动过期会话,并检测Codeigniter中的会话是否已过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 07:06