CodeIgniter Forums

Full Version: Unable to locate the specified class: Session.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
It sounds like the CI initialization hasn't progressed enough at that point.
Is there a problem having your logic at the beginning of your controller's constructor?

If it is something you want executed for every controller, you could make core/MY_Controller and build on that.
Another thought ... your hook is just a regular class, right?
You might have to...

$CI=&get_instance();
$CI->session->...
These two are good suggestions.
I will try them now.

If i remove session from autoload, and load it in post controller construction
session is successfully loaded in that controller. but not working in other controllers

Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Home::$session

Filename: controllers/Home.php

Line Number: 16

Backtrace:

File: C:\codeigniter\application\controllers\Home.php
Pre-hooking controller construction means that you don't have anything loaded inside the controller object so the last suggestion of ciadmin will help you.

BTW instead of prehooking controllers I can suggest another tactic using MY_Controller which will be used from your controllers and will extend CI_Controller..
There you will have real control of the ci controller construct + you can add any custom common method for all controllers.
(11-12-2014, 02:26 AM)sv3tli0 Wrote: [ -> ]Pre-hooking controller construction means that you don't have anything loaded inside the controller object so the last suggestion of ciadmin will help you.

BTW instead of prehooking controllers I can suggest another tactic using MY_Controller which will be used from your controllers and will extend CI_Controller..
There you will have real control of the ci controller construct + you can add any custom common method for all controllers.

It is hard to help the Original Poster, as there is no mention as to what the goal of the pre-hook is.

I have only found one use for the hooks in my projects.

I tend to use the My_Controller approach, which gives me all I need, as you can hook into the __construct and the __destruct to take care of what you need to at the start and then end of a run.

I can see a use for the hook if you have some analytics and have the page cache system running.
The error happens here when CI can't find a view file.
Well I think that I found the solution, I'm having this issue in just one controller, that have the same name of a library, so when I try to execute the controller that have the same name of the library this erros happened. So I just renamed my controller e voila no problem anymore.

I hope this helps!!
Pages: 1 2