CodeIgniter Forums
How simply work session ? - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: Libraries & Helpers (
+--- Thread: How simply work session ? (/showthread.php?tid=77814)

How simply work session ? - lolo57 - 10-21-2020


I try to use session() but I get this error :
{PHP internal code}   —  CodeIgniter\Debug\Exceptions->shutdownHandler ()

I want to set session globally in BaseController and simply use session() to set my session.

My session is working if I use php superglobal $_SESSION[] but impossible to use session().

Please give me the code to insert into BaseController, normally I can simply put code like this in my controller :

session('test')='my test';
echo session('test');

No ?

I'm lost trying many many thing !

RE: How simply work session ? - includebeer - 10-24-2020

There's multiple way to get/set session data. Here's some examples, see the links for more details.

Adding session data:
PHP Code:
$newdata = [
        'username'  => 'johndoe',
        'email'     => '[email protected]',
        'logged_in' => TRUE



Retrieving session data:
PHP Code:
$item session('item');
$item $session->get('item'); 

RE: How simply work session ? - paulbalandan - 10-24-2020

What is the actual error message? What you are showing is only the backtrace.

RE: How simply work session ? - InsiteFX - 10-24-2020

Use the session helper method like this works on all session methods using chaining.

PHP Code:
// seesion helper using method chaining.