CodeIgniter Forums
weird sessions problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: weird sessions problem (/showthread.php?tid=5055)



weird sessions problem - El Forum - 01-03-2008

[eluser]AtlantixMedia[/eluser]
Hello,

I would really appreciate if someone could help me out with this:

I have a table where I store error messages which are then retrieved by a function, stored in a session cookie, and retrieved once again by the controller for showing.

Code:
$url = 'whatever';
$Msg = $AdminMsg[$code]['AdminMsg_Msg'];    
$Tmr = $AdminMsg[$code]['AdminMsg_Timer'];

$str = $Msg . '|' . $Tmr . '|' . $url;
$CI->session->set_userdata('msg', $str);

now for some messages, this works perfectly. for others, it doesn't, meaning the $str is not successfully stored by set_userdata. for example, the msg

"Your optional info has been changed.<br />
You will now be redirected to your account page"

is among those that don't work when it gets assigned to $Msg directly from the db table array. However, if I do this:

Code:
$Msg = "Your optional info has been changed.<br />
You will now be redirected to your account page";

it works perfectly. can someone shed some light on this? I'm totally lost. thanks


weird sessions problem - El Forum - 01-03-2008

[eluser]Peter Ivanov[/eluser]
Hi there,

maybe your session has bee cleaned up.

read this one it might help you

http://www.captain.at/howto-php-sessions.php


weird sessions problem - El Forum - 01-03-2008

[eluser]AtlantixMedia[/eluser]
hello,

thanks for your reply. not sure if that's the case though. as I said, it WORKS if I put the message contents inside a local variable as opposed to getting them from the db. then again, it doesn't work only with some messages


weird sessions problem - El Forum - 01-03-2008

[eluser]AtlantixMedia[/eluser]
any other idea? thanks


weird sessions problem - El Forum - 01-03-2008

[eluser]sandwormusmc[/eluser]
So what happens when you:
Code:
print_r($AdminMsg[$code]['AdminMsg_Msg']);

Also, shouldn't the following have a $this-> preceding the CI?
Code:
$CI->session->set_userdata('msg', $str);



weird sessions problem - El Forum - 01-03-2008

[eluser]AtlantixMedia[/eluser]
[quote author="sandwormusmc" date="1199412108"]So what happens when you:
Code:
print_r($AdminMsg[$code]['AdminMsg_Msg']);
[/quote]

the message gets printed ok

[quote author="sandwormusmc" date="1199412108"]
Also, shouldn't the following have a $this-> preceding the CI?
Code:
$CI->session->set_userdata('msg', $str);
[/quote]

the function is in a helper file. that is the reason $CI is used instead of $this

again, this works with most messages, but not all