• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to verify a session in the view? It is possible?

#1
[eluser]Tomer Simis[/eluser]
I'm creating a site with a login panel, and when the user log on, it would display a message, but i dont know how to do this in CodeIgniter.

In normal PHP, its like this:

Code:
if(isset($_SESSION['login'])){
    echo '<p>You are logged.</p>';
    
        if($_SESSION['type'] == 'admin'){
        echo  '<p>Im a admin</p>';
        }
}else{
    echo '<p>You are not logged.</p>';
}

but in codeigniter its hard, can i check the session in the view? or i need to pass the status from the controller?

Please, help me guys
Thanks

#2
[eluser]cahva[/eluser]
In normal CI, its like this: Smile
Code:
if ($this->session->userdata('login'))
{
    echo '<p>You are logged.</p>';
...

#3
[eluser]Tomer Simis[/eluser]
It works =DD
Thanks very much!!!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.