Welcome Guest, Not a member yet? Register   Sign In
Problem with constructor in library
#1

[eluser]CIfan1000[/eluser]
Hi guys!

I have the following simple library, it works fine without the constructor but when I put in the constructor I get:

Quote:Fatal error: Cannot access parent:: when current class scope has no parent in C:\Backup\Apache2.2\htdocs\CodeIgniter\system\application\libraries\Myauth.php on line 15

Any help would be very much appreciated!

Code:
<?php

    if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Myauth
    {

        // Create constructor to load CI libaries and helpers:
        function Myauth()
        {
            parent::Controller();
        }


        function check_if_logged_in()
            {
                $CI =& get_instance();
                $CI->load->library('session');

                // Redirect user to login page if user is not authenticated:
                if ($CI->session->userdata('UserStatus') != "Authenticated")
                    {
                        $CI->session->set_flashdata('title', 'Not logged in');
                        $CI->session->set_flashdata('message_title', 'Not logged in');
                        $CI->session->set_flashdata('message_body', 'In order to use this page you need to log in.');
                        redirect('message/message');
                    }
            }
    }

?>

Thanks!


Messages In This Thread
Problem with constructor in library - by El Forum - 11-16-2008, 09:20 AM
Problem with constructor in library - by El Forum - 11-16-2008, 09:30 AM
Problem with constructor in library - by El Forum - 11-16-2008, 09:44 AM
Problem with constructor in library - by El Forum - 11-16-2008, 03:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB