• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Object storage and retrieval in session

#1
[eluser][At!][/eluser]
Hello,

I'm trying to store an entire object, being a custom library (not extending any of CI libraries) to a session, but I' not succeeding.

I get an error from CI saying it can not convert object to string.

I'm using CI version 1.7.1, Apache 2 with CI Sessions set to use Database storage (which works fine under normal uses)

I've applied the patch that was mentioned in earlier post(s) but seems like that did not work as expected.

Another issue I'm having is once I've stored the object to a session how do I retrieve it, correct me if I'm wrong, but storing of the object from the controller with Session lib auto-loaded would be like:

....
//load my library
$this->load->library('custom_library', '','mylibrary');

...
//do stuff with the library
...

//store the library states as the library should be load again on refresh
$this->session->set_userdata('custom_name', $this->mylibrary);

The above does gives an error

another issue I have is retrieving library from the stored session, currently I'm using.

$this->mylibrary = $this->session->userdata('custom_name');


I use to be able to do this with normal PHP sessions so I would assume the logic is the same.


Kindly assist, and thank you in advance.

#2
[eluser]Wuushu[/eluser]
In your case, do you think serialize it before store and un-serializing it after retrieval would help?

#3
[eluser][At!][/eluser]
But doesn't CI do that automatically for me, but I shall try that and see of that helps


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.