Welcome Guest, Not a member yet? Register   Sign In
Set session expiration time based on user role in CodeIgniter 4
#1

Hi everyone,

I'm working with CodeIgniter 4 and I need to configure the session expiration time dynamically based on the user role at login.

I understand that, by default, CodeIgniter loads session settings from app/Config/Session.php, where the 'expiration' value is defined. However, this configuration is static and applied globally.

What I want to achieve is something like this:
  • If the user has the admin role, their session should last longer.
  • If the user has a standard role, the session should expire sooner.

I’m wondering if there’s a recommended way to override the session expiration time at runtime based on the user role. Is it possible to change the expiration after login, or would I need to implement a custom logic to handle expiration manually?

Any advice or example would be greatly appreciated.
Thanks in advance!
Reply


Messages In This Thread
Set session expiration time based on user role in CodeIgniter 4 - by Beewez - 04-11-2025, 06:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB