Welcome Guest, Not a member yet? Register   Sign In
Session saving probleb
#1

[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
#2

[eluser]drewbee[/eluser]
Code?
#3

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

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

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

[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
#6

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

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

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

[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?
#8

[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
#9

[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.




Theme © iAndrew 2016 - Forum software by © MyBB