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

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
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