如果会话过期,则自动重定向到首页-Codeigniter [英] If session expires, automatically redirect home - Codeigniter

查看:70
本文介绍了如果会话过期,则自动重定向到首页-Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

codeigniter中是否存在某个地方,如果用户的会话已过期(我不打算延长会话的过期时间),我可以配置自动重定向到我的根页?

Is there somewhere in codeigniter where I could configure an automatic redirect to my root page if the user's session is expired (I am not trying to extend the session expiration's time)?


示例:

Situational example:

用户登录,页面闲置一天,返回到
需要经过验证的会话的页面

User logs in, leaves page idle for one day, returns to page that requires validated session and sees PHP errors everywhere.

在这种情况下,我希望将任何内容重定向到我的根登录页面。

I'd prefer for anything in this situation to be redirected to my root login page.

谢谢!

推荐答案

将此内容放入您的构造函数中,因为当

put this content into your constructor function because when the controller run constructor will execute first.

 function __construct() {
        parent::__construct();
         if(empty($this->session->userdata("login_session_user")))
         {
         redirect(site_url(),'refresh');
         }
    }

这篇关于如果会话过期,则自动重定向到首页-Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆