Welcome Guest, Not a member yet? Register   Sign In
if else using session data
#1

[eluser]Unknown[/eluser]
I'm still a student and I want to have a little upgrade in my php programming
Usually when I make a login, I just redirect it into an admin view with some admin controls but this time I want the session data to display or not to display the admin controls using if statement in the index view.

so this is my code.
VIEWS
Code:
<?php if ($this->session->userdata('position')=='admin')?>
<?php  echo 'Welcome: '.$this->session->userdata('user_id').$this->session->userdata('lastname').$this->session->userdata('position'); ?>
When its logged in it echo
Welcome: 1 lastname admin
When its logged out it still echo
Welcome:


what I want is something like this if its logged in;
Welcome: 1 lastname admin
and when logged out it will not display the Welcome:

thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB