最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - extent codeigniter Session expiration - Stack Overflow

programmeradmin4浏览0评论

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 mand.

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

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 mand.

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

Share Improve this question asked Jul 6, 2013 at 12:50 RedRed 6,39813 gold badges66 silver badges113 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

发布评论

评论列表(0)

  1. 暂无评论