Welcome Guest, Not a member yet? Register   Sign In
Login (Checking exists (Using callback) and then checking against the DB
#11

[eluser]jedd[/eluser]
That's a little bit frightening (and not in a Carl Douglas kind of way).

This is your model, right?

Why are you using get_instance()? You shouldn't be redirect()ing from a model. Session should be autoloaded in your use case. Where are your processing your user / pass credentials from that form you showed earlier?
#12

[eluser]JamieBarton[/eluser]
This was the library, the code above was my first attempt at authentication. Very simple authentication too.

It was basic and didn't use a Model.

my Controller is:
Code:
<?php

class Session extends Controller {

    function Session()
    {
        parent::Controller();
        $this->load->library('auth');    
    }
    
    function index()
    {
      $this->layout->view('session/index');
    }
    
    function create()
    {
        
          if(isset($_POST['password']) && $_POST['password'] == "secret") {
            $this->auth->login();
            redirect('/panel');
        } else {
            redirect('session');
        }
    }
    
    function destroy()
    {
    $this->auth->logout();
    redirect('/');
    }
}

?>

The view:
Code:
<?php echo validation_errors(); ?>
<form action="/session/create" method="post">
  <input name="password" />
  <input type="submit" />
</form>

Session is the name of the Controller.

Totally not getting on with CodeIgniter at the moment, I was doing fine the other day with normal CRUD stuff, but when it came to sessions and authentication I just seem to have hit a brick wall and totally got me sick.


Regards,

Jamie
#13

[eluser]jedd[/eluser]
Ah, okay. I wondered why it shared the same name as your earlier model, but didn't look like a model.

I'd avoid a library here - it just complicates matters, and the logic should be (primarily) in your auth model.

I'd also avoid calling a class 'Session' - as this is a name that CI uses for one of its classes. I don't know if there would be clashes, but it probably doesn't engender clarity.
#14

[eluser]JamieBarton[/eluser]
I'll give the whole thing one more go tomorrow. What I might do is avoid the login just now, on the login controller just simply store some data i know will be there, like a user_id and logged_in as true

Then at the end of finishing my project fix the login. I think the only reason its complicating things is all the validation I want to do to be honest.
#15

[eluser]JamieBarton[/eluser]
Maybe it'll help me if I can see what a form_validation rule code actually looks like.

Like when i add in 'required' what is the actual code ran here, maybe this will help me in making my own callback_'s




Theme © iAndrew 2016 - Forum software by © MyBB