Session destroyed... Solved problem but I don't understand why |
[eluser]Unknown[/eluser]
Hello everyone! I've been coding for a while with CI and I must say it's very useful and easy to use. Nevertheless, today the weirdest thing happened to me when coding some stuff with sessions and I would like to know if any of you could explain me what happened. I have something like this in my code: controllers/user.php Code: function login(){ And the view is something like this: someview.html Code: ... It turns out that I log-in and then I'm redirected to index page, where I can navigate and visit any section (as logged-in user) without having any problem. That's OK. But if I go to user's home I appear as logged-in just once, this means that if I refresh the page I'm logged-out and the log-in form is showed again. I looked for a lot of possible solutions to this "problem"... like checking the server time zone, using database for sessions, disabling sessions to match user agent, even using another session library. Finally I discovered that the image I was showing in the view was calling "images/pic.png" and that was in fact a reference to http://mypage.com/user/home/images/pic.png. Somehow, that reference was causing all the trouble. I replaced the call to the image with "<?php echo base_url(); ?>images/pic.png" and I solved the problem. I don't understand why that reference was destroying my logged-in session.. I would really appreciate if someone explain that to me Regards
[eluser]InsiteFX[/eluser]
Because it could not find your image! When testing make sure you have error reporting turned on!
[eluser]Unknown[/eluser]
[quote author="InsiteFX" date="1334300280"]Because it could not find your image! When testing make sure you have error reporting turned on! [/quote] Thanks for replying. I know it was because it couldn't find my image... my question was pointing to how is that related to the fact that my logged-in session was being deleted when that happened. If I access to /user/home/blablblabla everything is OK, but if I access to user/home/bablablabla.png my session is destroyed. 404 errors has something to do with it?? Regards
[eluser]Aken[/eluser]
Check if your .htaccess defaults back to your application if a 404 error occurs. If so, there's something in the logic in there that's messing with your session. |
Welcome Guest, Not a member yet? Register Sign In |