[eluser]vertmonkee[/eluser]
I am just looking at creating my own library. I believe there are authentication libraries avilable but I'm keen to use this as a first try of writing my own library.
The question I have is about when to use get_instance, if I have a class as follows
Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//Library to deal with all authentication
class Authentication {
function Authentication() {
}
//Function to check users login credentials
function login($email, $password) {
//Check DB for user auth
}
//Function to check that a user is currently logged in
function loggedInCheck() {
$obj =& get_instance();
return $obj->session->userdata("session_id");
}
//Function to logout a user
function logout() {
//Destroy the current session
}
}
Do I have to use get_instance in all of my methods or can I just include it once and have all methods access it? If so hwo do I acheive this?
Thanks for any help