Welcome Guest, Not a member yet? Register   Sign In
How to set and read a flash variable?
#6

(06-30-2017, 02:08 AM)desbest Wrote: I'm using this code in the controller and I'm getting an error.


Code:
@session_start();
$_SESSION['notice'] = 'The user has been edited.';
$this->session->mark_as_flash('notice');


Undefined property: Admin::$session
Call to a member function mark_as_flash() on null

Read the documentation.

https://www.codeigniter.com/user_guide/l...sions.html

Quote:Sessions will typically run globally with each page load, so the Session class should either be initialized in your controller constructors, or it can be auto-loaded by the system. For the most part the session class will run unattended in the background, so simply initializing the class will cause it to read, create, and update sessions when necessary.

To initialize the Session class manually in your controller constructor, use the $this->load->library() method:

$this->load->library('session');
Once loaded, the Sessions library object will be available using:

$this->session
Reply


Messages In This Thread
RE: How to set and read a flash variable? - by Paradinight - 06-30-2017, 10:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB