drygauost253590142 2013-07-06 12:50
浏览 66
已采纳

extent codeigniter会话到期

I have $config['sess_expiration'] = 7200; on my config.php file, Which means that session last in 2 Hours.

By default the session is created up on user LOGIN. Now i want to last session based on User IDLE state.

So when user is active on page i need to renew the session.

Ex.

A POLL to server on every 2 minutes through ajax with current user status , IDLE or ACTIVE

if the status is ACTIVE then i want to extent/renew/update the session timeout for another 2 hours from the ajax call.

Infact IF the status is IDLE i will run a timer on web page and before it reaches its timeout (2 hours) i need to display a warning to user ==>

"Your Current session is about to expire. Do you want to renew session ?"

If user clicks YES then i want to extent the session for another 2 hours,else i will send an LOG OUT command.

So the Question is : How i renew/update/extent the session timeout programically ?

Also is there any other better solutions available.

I am using PHP 5 , Codeigniter 2.x , Bitauth( User Authentication ).

Thanks

  • 写回答

1条回答 默认 最新

  • dtx3006 2013-07-06 14:58
    关注

    Simply you can use the $config['sess_time_to_update'] = 30; //seconds which will update the session timeout if user is idle and session expiration time is over i.e $config['sess_expiration'] = 7200; and then user hits any link it will automatically logged out because CI check the session on each request that whether session expiration time is over or not of exceeds the expiration time then your session is destroyed . If user hits any request after one hour then your sess_time_to_update updates the sess_expiration lets say from now to two hours. By default, CI creates a new session id in a defined interval $config['sess_time_to_update'] = 30; i.e after every 30 seconds new session id will be created

    For a deep closely look you can see the Session.php in libraries sess_update() is the function which updates the session so you have a good idea what CI does if you are not using the database session then CI stores the information in cookie else it stores the data in the ci_sessions table

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题