Login system - handling same view that is different for user and guest |
[eluser]boltsabre[/eluser]
Yes, check for the logged in/out status MY_Controller, and have all other controllers extend it. You then have a choice of two options: 1. Loading a logged in or out view direct from your controllers depending on the logged in/out status. 2. Load the same view from your controller, but inside that view control what is being displayed to logged in/out users (this is my preference as option one creates 2 views for every page, updating something shared means you have to update it in two places, not very DRY). To achieve the second option, in MY_Controller you can load the logged in/out status into a variable and load it directly into all views using this line of code Code: $this->load->vars($array) Then if your views it's a simple matter of displaying / not displaying content to users depending on their status. In MY_Controller, lets say if logged in $logged_in = true; if not logged in $logged_in = false; and that you've loaded it by using the above code snippet. In your view it's now a simple matter of Code: <?php if($logged_in): ?> |
Messages In This Thread |
Login system - handling same view that is different for user and guest - by El Forum - 01-10-2013, 04:23 PM
Login system - handling same view that is different for user and guest - by El Forum - 01-11-2013, 03:08 AM
Login system - handling same view that is different for user and guest - by El Forum - 01-11-2013, 07:34 AM
Login system - handling same view that is different for user and guest - by El Forum - 01-11-2013, 08:17 AM
|