![]() |
Codeigniter Controller Execution - 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: Codeigniter Controller Execution (/showthread.php?tid=21532) |
Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] I'm having the following problem. To simplify it this is what I'm testing: - sessions are turned off - compress_output is off in one of the functions in my controller i put the following code: Code: session_start(); and i keep refreshing that page. What I expect for every refresh (not the initial refresh) is that the first number printed will equal to the last number printed in last page visit. eg: Code: //2nd page visit: however most of the time it is always few seconds off. when i tested that code without using codeigniter it was correct for every refresh. It seems as if codeigniter is running that controller function twice. Does anybody know where the problem comes from? I've also tested that code with standard codeigniter session and it still is few seconds off. Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] Hmmm... this is getting interesting. It seems that it's not the problem is not with code igniter but with how php classes are instantiated. If the controller execution takes more than 1 second it will offset my $_SESSION['test'] variable. Check this out: Code: class test{ Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] Hmmm... Nevermind it's not the fault of the constructor, now I have no idea what is going on, check this out: Code: session_start(); It has something to do with how long the entire page executes. But I dont know what it really is. Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] and here's much simpler example: Code: session_start(); now why is $_SESSION['test'] offset by 3 seconds? Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] another discovery, this only happens in firefox... tried it in ie8 and chrome and it seems to be working fine. how could it be the problem with the browser if sessions are stored on the server and browser only has session_id in the cookie? Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] And this seems to fix it: Code: session_start(); Codeigniter Controller Execution - El Forum - 08-12-2009 [eluser]plxkarl[/eluser] Actually the previous solution didn't fix it. There was nothing wrong with that script at all, the problem was with the firefox plugin 'YSlow', it was turned on and for every request to the server I made YSlow was making another one (after my request completed) which in turn was modifying my session variable's time(). PEACE!!! |