Welcome Guest, Not a member yet? Register   Sign In
Using a var on every site
#1

[eluser]Unknown[/eluser]
Hello,

i have a question. I use to the Session on every Page to check if it is an user.

Code:
$data['session'] = $this->session->userdata('logged_in');


Do i need to insert it on every page? Or ist there a workaround?

#2

[eluser]jairoh_[/eluser]
no need to set that in a $data array to access that in the view, you can call the session anytime, anywhere.
#3

[eluser]Unknown[/eluser]
How can i use it?

#4

[eluser]Pert[/eluser]
Example for a view file
Code:
<? if ($this->session->userdata('logged_in') === true) : ?>
   User is logged in.
<? else : ?>
   User is not logged in.
<? endif ?>
#5

[eluser]boltsabre[/eluser]
Check/assign your session variable in your "MY_Controller" and use:
Code:
$this->load->vars()

It will then be available in every view.

If you don't have a "MY_Controller" yet, simply research it on google, there are heaps of blog posts, threads on here and stackoverflow about this subject.




Theme © iAndrew 2016 - Forum software by © MyBB