Expire session automatically and detect if the session has expired in Codeigniter

后端 未结 5 1650
粉色の甜心
粉色の甜心 2021-02-06 13:37

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 aut

5条回答
  •  清歌不尽
    2021-02-06 14:30

    When you are starting the session, store the current time in a session variable. You can use a session_expire_checker function which will check current time and stored time to determine whether the session has expired. You should call the function from the constructor so that every function call will use this function automatically. In that function if session is expired, you redirect to another controller.

    You have to use separate controller for the redirected URL, otherwise there would be infinite redirect.

提交回复
热议问题