Autoload Session driver issue #1800

Closed
namaless opened this Issue Sep 14, 2012 · 11 comments

5 participants

@namaless

Hi, I try to add into config/autoload.php:

$autoload['drivers'] = array('session');

But if add one helper and try to use this driver not working.

Before load session driver need to load with:

$this->load->driver('session');

With this working property.

@dchill42

I assume you're using the latest version from the develop branch. If I understand correctly, you're autoloading a helper

$autoload['helper'] = array('some_helper');

and the Session driver

$autoload['drivers'] = array('session');

and the helper is being loaded, but the Session driver is not. Which helper are you loading? Are there any error messages being displayed or logged? Do you have any class extensions installed (such as Session or Loader)? I have encountered one scenario where someone using Sparks had problems because Sparks uses its own loader, which wasn't honoring the latest changes.

Other than that, loading the new Session driver has been tested pretty thoroughly - I need more detail to understand why it's not working for you.

@namaless

I create 'session_helper.php' and one function inside 'session_userdata'.

Call $CI =& get_instance();

but $CI->session not loaded.

use autoload helper for session_helper and autoload for session driver.

thanks

@appleboy

I think you must create new library that load CI session driver.

Refer the following URL: http://codeigniter.com/user_guide/general/creating_libraries.html

@namaless

Not need new library...

The problem is the drivers not autoloading before helpers and when use autoload helpers the drivers not loaded.

@dchill42

I think I understand now. The problem is that helpers get autoloaded before libraries and drivers. Since many helpers rely on and enhance libraries and drivers, it would make sense to change that order in the autoloader.

@namaless

Yes good choice :)

Libraries and Drivers need loaded before helpers (is logic).

@dchill42

@narfbg, @alexbilbie If we were to make this change, I think the easiest would be to include it in #1744, where autoload unit testing is introduced. That way the autoload sequence could be changed and the unit test could be updated to match at the same time. What do you think?

@narfbg

And what if then somebody complains that their library depends on a helper?

IMO, @appleboy has said it - if you're going to depend on a library, either create another library or make an extension to the one you're utilizing.

Plus, why would you need a session helper?

@dchill42

All good points.

@namaless

Use session helper for view files. No like use $this into views. Not important for me but I found this problem and posted here :)

Thanks for support !!

@narfbg narfbg closed this Oct 16, 2012
@tim-peterson

Can someone show a gist of how to autoload the session driver? I'm having trouble following from these threads how the code in the various /application files needs to be changed.

I'm using CI 2.1.2 and would like to make the switch to 3.0 but it seems like this a common sticking point for the CI community

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment