CodeIgniter Forums
How to verify a session in the view? It is possible? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to verify a session in the view? It is possible? (/showthread.php?tid=23560)



How to verify a session in the view? It is possible? - El Forum - 10-14-2009

[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


How to verify a session in the view? It is possible? - El Forum - 10-14-2009

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



How to verify a session in the view? It is possible? - El Forum - 10-14-2009

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