Part of the EllisLab Network
   
 
Session question!
Posted: 03 July 2009 07:07 PM   [ Ignore ]  
Summer Student
Total Posts:  26
Joined  11-09-2007

Hi i recently create a login system but i encounter one problem about session.

i want to do inactivity logout for 30 minutes. But the user can stay on forever if he keep active.

At first, i think set sess_expiration for 30min in config file will do the job. But i am wrong.

Is there anyway i can update that sess_expiration var?

Please help me how should i code it?

Thanks a lot

Profile
 
 
Posted: 03 July 2009 08:11 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  18
Joined  07-03-2009

The expiration clock only starts to tick after the last activity on the session, and resets on every acivity (code from the session library):

if (($session['last_activity'] + $this->sess_expiration) < $this->now)
{
   $this
->sess_destroy();
   return
FALSE;
}

Maybe you could store the login time in the session and destroy the session in the code after the preferred ammount of time?

Profile
 
 
Posted: 04 July 2009 02:55 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  26
Joined  11-09-2007
Haloperidol - 03 July 2009 08:11 PM

The expiration clock only starts to tick after the last activity on the session, and resets on every acivity (code from the session library):

if (($session['last_activity'] + $this->sess_expiration) < $this->now)
{
   $this
->sess_destroy();
   return
FALSE;
}

Maybe you could store the login time in the session and destroy the session in the code after the preferred ammount of time?

Thanks for reply.

i am confused. As you mention, “The expiration clock only starts to tick after the last activity on the session”. It actually doing what i want. Destory the session after inactivity for “sess_expiration” time? And the user can stay online forever if he active within “sess_expiration” time??

Thanks

Profile
 
 
Posted: 04 July 2009 03:05 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  18
Joined  07-03-2009
helphelp - 04 July 2009 02:55 PM
Haloperidol - 03 July 2009 08:11 PM

The expiration clock only starts to tick after the last activity on the session, and resets on every acivity (code from the session library):

if (($session['last_activity'] + $this->sess_expiration) < $this->now)
{
   $this
->sess_destroy();
   return
FALSE;
}

Maybe you could store the login time in the session and destroy the session in the code after the preferred ammount of time?

Thanks for reply.

i am confused. As you mention, “The expiration clock only starts to tick after the last activity on the session”. It actually doing what i want. Destory the session after inactivity for “sess_expiration” time? And the user can stay online forever if he active within “sess_expiration” time??

Thanks

Yes thats right, the session will not be destroyed if the user is active. I only advised to store the login time in a variable because i thought you want to force the user to logout even if he was active.

Profile
 
 
Posted: 17 August 2009 02:07 AM   [ Ignore ]   [ # 4 ]  
Grad Student
Avatar
Rank
Total Posts:  41
Joined  07-26-2009

hello people,
I’m new to CI. Well I’m just creating a login page for Administrator. I just want to create a session when the record is found in database….So please help me

Thanx smile

 Signature 

Harpreet Bhatia
Web: http://www.bluejavax.com
Email: bluepicaso@gmail.com

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120316 Total Logged-in Users: 55
Total Topics: 126437 Total Anonymous Users: 3
Total Replies: 664887 Total Guests: 510
Total Posts: 791324    
Members ( View Memberlist )