![]() |
Session not working in some pages - 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: Session not working in some pages (/showthread.php?tid=52659) Pages:
1
2
|
Session not working in some pages - El Forum - 06-20-2012 [eluser]abhinavp[/eluser] Hello There, I came across with some strange problem, I am using codeigniter's session library to maintain user's login status. It is working fine. But when on one page I am trying to save another session its not working. I am not able to get session's value in another function. I did some this like this: Code: $data = array( After redirecting, I am trying to access 'imagedata' session value but it returns empty. My session setting in config.php is as follows: Code: $config['encryption_key'] = 'jdgfkjsagd jagshdkjsaghdkjagsdj'; Please help me. Session not working in some pages - El Forum - 06-20-2012 [eluser]MRosenello[/eluser] Did you make sure you loaded the session library in the controller for that page? I believe that this has to be loaded on every controller you intend to use the session. Or I believe you can load it by default for everything. Code: public function __construct() Session not working in some pages - El Forum - 06-20-2012 [eluser]abhinavp[/eluser] Hi MRosenello, Thanks for your reply! But I defined it in autoload.php. So that on every page i can use sessions. Session not working in some pages - El Forum - 06-20-2012 [eluser]CodeIgniteMe[/eluser] which part of your codes did you put this? Quote: you can check your session values by echoing Code: $this->session->all_userdata(); I think you probably had some errors in your code. note your array, the last comma after your last element Session not working in some pages - El Forum - 06-20-2012 [eluser]abhinavp[/eluser] Hello CodeIgniteMe, Thanks for your reply, I dont know about that function to print all session userdata. But I debugged the code, there is no problem in code, the actual is after saving session, I redirected the page on another one. On redirect page i am not able to access that session values. Session not working in some pages - El Forum - 06-20-2012 [eluser]CodeIgniteMe[/eluser] what browser are you using? what is displayed after you put this? Code: $this->session->all_userdata(); Code: $data = array( Code: $this->session->userdata('item'); Session not working in some pages - El Forum - 06-21-2012 [eluser]Unknown[/eluser] Having exactly the same problem. My session data is lost after redirect, but if I call a function within the class without redirecting, everything works well and I can access the session stored data. Code and Logic is double checked, no errors. Thanks. Session not working in some pages - El Forum - 06-21-2012 [eluser]CodeIgniteMe[/eluser] Is it only occurring on a specific browser? What browser are you using? Session not working in some pages - El Forum - 06-21-2012 [eluser]abhinavp[/eluser] I tested in most common browsers like mozilla, chrome but had no luck. Session not working in some pages - El Forum - 06-21-2012 [eluser]CodeIgniteMe[/eluser] Have you checked the possibility that you might have unset some or all session data on your script/s? |