Welcome Guest, Not a member yet? Register   Sign In
Problem setting data for session, not sure how to accomplish with CI
#1

[eluser]RJ[/eluser]
Hello,

The array() portion of this statement doesn't work. Not sure who to complete this line with CI, any thoughts?

Code:
$this->feedback_pos = empty($this->session->userdata('feedback_pos'))? array() : unserialize($this->session->userdata('feedback_pos'));
#2

[eluser]RJ[/eluser]
actually i don't think you can work with the session cookie data in this way.. damn!
#3

[eluser]TheFuzzy0ne[/eluser]
You can't use the return value of a function with empty() the way you are, you'd need to do it like this:

Code:
$this->feedback_pos = $this->session->userdata('feedback_pos');
$this->feedback_pos = ( ! $this->feedback_pos) ? array() : unserialize($this->session->userdata('feedback_pos'));

However, since the session class returns FALSE if the key doesn't exist, you might as well just do this:
Code:
$this->feedback_pos = ( ! $this->session->userdata('feedback_pos') ? array() : unserialize($this->session->userdata('feedback_pos'));

Hope this helps.
#4

[eluser]RJ[/eluser]
That seems to help; further down on the page this is throwing an error, any ideas here oh great fuzzyone?
Code:
$this->session->set_userdata('feedback_pos') = serialize($this->feedback_pos);

Error
Quote:Can't use method return value in write context in W:\www\s\application\models\System_notice.php on line 47

47 being the line i supplied above Smile
#5

[eluser]TheFuzzy0ne[/eluser]
You're effectively trying to set a function, which doesn't work...

Try this instead:

Code:
$this->session->set_userdata('feedback_pos', serialize($this->feedback_pos));

All the best.
#6

[eluser]RJ[/eluser]
Works perfectly and helped me solve other issues, thank you.




Theme © iAndrew 2016 - Forum software by © MyBB