Welcome Guest, Not a member yet? Register   Sign In
CI4 - session not persisting
#11

(10-23-2018, 03:44 AM)InsiteFX Wrote: I start the sessions in a Base controller that all the other controllers extend.

In the constructor I have the sessions like so.

PHP Code:
/**
 * __construct ()
 * -------------------------------------------------------------------
 *
 * Class    Constructor
 *
 * NOTE: Not needed if not setting values or extending a Class.
 *
 */
 
public function __construct()
 {
 
// Ensure session is started and running
 
if (session_status() == PHP_SESSION_NONE)
 {
 
// session has not started so start it
 
session()->start();
 }
 } 

I can then use the $__SESSION global any place in the app even views.

That's handy to know. I did have "$session = \Config\Services:Confusedession();" in the constructor of my base controller but issue seemed to be with PHP FPM settings. Sessions were working fine for the one (and only) live site on the same server and when I setup another test site, sessions just didn't want to work!!
Reply


Messages In This Thread
CI4 - session not persisting - by happyape - 10-18-2018, 10:08 AM
RE: CI4 - session not persisting - by donpwinston - 10-18-2018, 01:16 PM
RE: CI4 - session not persisting - by happyape - 10-18-2018, 11:52 PM
RE: CI4 - session not persisting - by happyape - 10-19-2018, 06:49 AM
RE: CI4 - session not persisting - by sv3tli0 - 10-19-2018, 06:58 AM
RE: CI4 - session not persisting - by happyape - 10-19-2018, 07:06 AM
RE: CI4 - session not persisting - by happyape - 10-19-2018, 07:51 AM
RE: CI4 - session not persisting - by puschie - 10-22-2018, 06:16 AM
RE: CI4 - session not persisting - by happyape - 10-23-2018, 01:12 AM
RE: CI4 - session not persisting - by InsiteFX - 10-23-2018, 03:44 AM
RE: CI4 - session not persisting - by happyape - 10-23-2018, 05:40 AM
RE: CI4 - session not persisting - by InsiteFX - 10-23-2018, 08:31 AM
RE: CI4 - session not persisting - by happyape - 10-23-2018, 10:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB