• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.env Settings ignored in session driver

#1
Hey guys i am having a very strange issue. 

My Config/App.php file is the default one, where the session driver is set as FileHandler. 

I would like to use a database for this, so i change my .env settings to:

Code:
app.sessionDriver = CodeIgniter\Session\Handlers\DatabaseHandler
app.sessionCookieName = sess
app.sessionSavePath = ci_sessions
app.sessionMatchIP = false
app.sessionTimeToUpdate = 300
app.sessionRegenerateDestroy = false

Unfortunately the application still uses the FileHandler, and not the DatabaseHandler

Things i have checked:
- the ci_sessions table is created via the migration;
- if i change the settings in Config/App.php to DatabaseHandler it seems to work (i can see data written to the ci_sessions table)
- i used this to debug my settings:
PHP Code:
d(env('app.sessionDriver'));
d(config('App')->sessionDriver); 

And the results are:

Code:
env(...) string (44) "CodeIgniter\Session\Handlers\DatabaseHandler"
⧉Called from .../app/Controllers/Dashboard.php:18 [d()]
config(...)->sessionDriver string (40) "CodeIgniter\Session\Handlers\FileHandler"
⧉Called from .../app/Controllers/Dashboard.php:19 [dd()]


So it seems to me that my settings are in place. 

What am i missing where? Isn't .env always overriding the settings in Config/App.php?
Reply

#2
CI 4.1.1
env(...) string (44) "CodeIgniter\Session\Handlers\DatabaseHandler"
⧉Called from .../app/Controllers/Home.php:12 [d()]
config(...)->sessionDriver string (44) "CodeIgniter\Session\Handlers\DatabaseHandler"
⧉Called from .../app/Controllers/Home.php:13 [d()]
Reply

#3
I am using 4.1.1 too, and yet behavior is different. My question is how can i troubleshoot this?
Reply

#4
Replace your configs with the default configs. Maybe some setting affects this behavior.
Reply

#5
Just a comment - I have had "strange" problems with env lately - https://github.com/codeigniter4/CodeIgni...ssues/3992
I have stopped relying on the magic .env for many things and replaced with standard php getenv() in this way:

$this->default['password'] = getenv('CONFIG_RDS_PASSWORD', true);

I still set CONFIG_RDS_PASSWORD in my .env.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.