Welcome Guest, Not a member yet? Register   Sign In
$_SESSION and __PHP_Incomplete_Class_Name
#1

[eluser]paynterc[/eluser]
What is the best way to use native php sessions with CI ?

I was trying to store my search results in the $_SESSION variable and it worked fine the first time around, but when I reload the page, the CI_DB_mysql_result gets put into __PHP_Incomplete_Class_Name.

I read that this happens when you try to start the session before defining the class. I tried moving around the "session_start()" line but it always seemed to result in the "output before session start" error, or I got the __PHP_Incomplete_Class_Name problem again.

I tried using the phpsession.php library:

http://ellislab.com/forums/viewthread/44945/

but I still have the __PHP_Incomplete_Class_Name problem.

Has anyone else had this problem?
#2

[eluser]Unknown[/eluser]
I just had and solved this problem. I did as you wrote, put the class declaration before starting the session.
I use the CI session library and the code looks like this after I made it work:
Code:
$this->load->library( 'class_name' );
$this->load->library( 'session' );

Previous to the problem I auto loaded the session library but that was apparently a mistake :/

There is probably a solution if you want to auto load the session library. Might be possible though hooks, but that might mean always loading you other class...
#3

[eluser]dootzky[/eluser]
I just had the same problem. Solution is either that you've described here, OR, you can just load your class (which should be in Libraries folder for convenience) just BEFORE session class, in autoload.php config file, like this:

$autoload['libraries'] = array('database', 'cart', 'session');

and that's it!
cheers,
dootzky
#4

[eluser]juworld[/eluser]
thanks for the post. I had the similar problem and now its fixed.

if you don't want to mess with the load order, you can just use serialize f().

$_SESSION['cart'] = serialize($cart)

After reloading, i use

$this->load->library('cart');
$cart = unserialize($_SESSION['cart']);

cheers!




Theme © iAndrew 2016 - Forum software by © MyBB