CodeIgniter Forums
Session saving probleb - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Session saving probleb (/showthread.php?tid=11610)



Session saving probleb - El Forum - 09-16-2008

[eluser]emperius[/eluser]
I have controller called "pages" and view called "show".
When I try to add session variable in the controller then everything is fine, variable is saved and works on any page, however when i try to do the same in view then variable isn't saved in the session when going to the other page.

Before it worked in other projects.

What may be the reason of such thing?

PS I'm using session library


Session saving probleb - El Forum - 09-16-2008

[eluser]drewbee[/eluser]
Code?


Session saving probleb - El Forum - 09-16-2008

[eluser]emperius[/eluser]
Code:
$this->session->set_userdata('test', '123');



Session saving probleb - El Forum - 09-16-2008

[eluser]drewbee[/eluser]
Your not giving me very much to look at.

Are you calling $this->session->userdata('test'); on the other page?


Session saving probleb - El Forum - 09-16-2008

[eluser]emperius[/eluser]
In the view I'm triyng to assign session variable like this
Code:
$this->session->set_userdata('test', '123');

And in other place I try to call it like this
Code:
$v = $this->session->userdata('test');

and the variable $v is empty


Session saving probleb - El Forum - 09-18-2008

[eluser]Christopher Blankenship[/eluser]
Umm, that isn't an associative array.

Code:
$newdata = array(
                   'test'  => '123',
               );

$this->session->set_userdata($newdata);



Session saving probleb - El Forum - 09-18-2008

[eluser]Pascal Kriete[/eluser]
It doesn't need to be when you're only setting one value:
Quote:If you want to add userdata one value at a time, set_userdata() also supports this syntax.
Code:
$this->session->set_userdata('some_name', 'some_value');
Sounds to me like it might be a cookie issue. Is your browser set to allow cookies? Have you tried with a different browser?


Session saving probleb - El Forum - 09-18-2008

[eluser]emperius[/eluser]
[quote author="inparo" date="1221771231"]It doesn't need to be when you're only setting one value:
Quote:If you want to add userdata one value at a time, set_userdata() also supports this syntax.
Code:
$this->session->set_userdata('some_name', 'some_value');
Sounds to me like it might be a cookie issue. Is your browser set to allow cookies? Have you tried with a different browser?[/quote]

No. If I'm triying to assign variable in controller everything works fine. Byt in view doesn't


Session saving probleb - El Forum - 09-18-2008

[eluser]Christopher Blankenship[/eluser]
gotcha. Never used it for less than at least 4 or 5 items, before. Thanks for that bit of information for future reference if I ever use only 1 item. Generally though I need more than that.