Problem with CI4 session |
Do not know why, the session in the constructor is not working but in other method. Help me to find this out. Thanks in advance.
PHP Code: <?php
I load my session in the BaseController like below and it works just fine.
Add a: PHP Code: use Config\Services; PHP Code: // Ensure that the session is started and running By the way I use the session files driver and save my sessions to the writable folder. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Now I am loading session in my BaseController.
PHP Code: <?php Then in my Controller. But still the same result. PHP Code: <?php
You do not need the initController in a regular controller it is inherited from the
BaseController, as long as you extend your controllers from BaseController. Just load your session in the BaseController then access the session in any method. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
BaseController:
PHP Code: <?php Create new Test Controller: PHP Code: <?php namespace App\Controllers; Add this to the bottom of Views welcome_message.php PHP Code: <p> You will see that sessions do work. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
please help.
i have a libary code like bellow libarary <?php namespace App\Libraries\Mylibrary; class Mylibrary{ function hitung(){ $angka = 2; return $angka; } } controller : <?php namespace App\Controllers; use App\Libraries\Mylibrary; class Home extends BaseController { function sesi(){ $this->session->set('abc','item'); if ($this->session->get('abc')!='item') { echo "string"; }else{ echo "strong"; } echo hitung(); } } the error Call to undefined function App\Controllers\hitung() thanks. |
Welcome Guest, Not a member yet? Register Sign In |