Set Session Expiration Time Manually-CodeIgniter

Siregar picture Siregar · Aug 10, 2011 · Viewed 92.6k times · Source

How can I set session expiration time dynamically in codeigniter?

For example, if a user logs in and has the role of admin, the expiration time should be longer than if a user logs in who does not have an admin role.

Thanks.

Answer

AlphaMale picture AlphaMale · Aug 10, 2011

You can update your session expiration time by increasing this variable in config file:

$config['sess_expiration'] = 'somevalue'.

Set $config['sess_expiration'] = 0, if you want it to never expire.

Here's a good discussion on CI forums:

Dynamically set configuration on session expire doesn’t work