Welcome Guest, Not a member yet? Register   Sign In
User Login
#1

[eluser]paradoxic[/eluser]
I want to design a login system that works across basically all the pages on my site. I want to have a login form/user control panel at the top of every page (I have a global header.php view file that I want to place it in). What is the best way to approach this with Code Igniter?

Thanks in advance.
#2

[eluser]xwero[/eluser]
The simplest solution is to put a login form in the page header. The action goes to a login controller but you cache the current page in a session or flashdata variable so you can redirect to the page where the login is tried. Or you just redirect them to the page matching the login privileges. That is up to you Wink
#3

[eluser]paradoxic[/eluser]
Is there any way to load a controller into the header view file? So basically the controller file (controllers/login.php) would be loaded, it would check the session and then display either a login form or a user account cpanel. I tried to load it in the header.php view file using this code:
Code:
<? $this->load->login; ?>

But this gave me the following error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$login

Filename: views/header.php

Any suggestions?
#4

[eluser]stevek42[/eluser]
Since I don't like doing instance related stuff directly in my views, I will have my main view (header.php for instance) load a view called something like 'loginblock'. Since I don't like massive coding in my views, I have 'loginblock' calling a helper that gets the instance, runs the proper functions, and returns what I need to the 'loginblock' view.

Of course, this may not be the (or even a) right way to do it, I asked a few minutes ago in this thread but I haven't seen a response yet.
#5

[eluser]wiredesignz[/eluser]
You should both consider using Modular Extensions, it allows HMVC style calls between module controllers, and can also be used provide the logic behind view partials.




Theme © iAndrew 2016 - Forum software by © MyBB