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 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法