Sessions - Bug? |
[eluser]amw_drizz[/eluser]
I used your recommendations and I still get the same error. header output started and sessions failed...
[eluser]majidmx[/eluser]
What you have in : main_site\controllers\auth.php Line 18 ? There should be some out put which prevents the headers from being started.
[eluser]majidmx[/eluser]
ok, so you have some extra spaces after ?>, try to delete whatever is after the ?> including any space, line etc and save the file.
[eluser]Fierymind[/eluser]
I confirm this post, when using sessions in models, it fail "sometimes". I'm building some software for a company, and while the software is working fine from my office computer, there was no way for software to work in company office! software simply can't write any cookies and after some debugging, I found the "Cannot modify header information - headers already sent ..." error. There is no way to solve this problem at company office and suddenly it works (no code modification happen, no ?> in any PHP file). after 100s of trails in many computers in the company, I got the result sessions "sometimes" work ... I hate the word "sometimes" in programming. anyways, I read this post and put the session work in the controller instead of model, uploaded the new stuff and called the company to try again .. they tried everything and program did NOT fail even once. So I guess, sessions does NOT work probably within model, I think this must be included in CI manual. (I'd like to thank everyone behind the CI project, CI is PERFECT PHP framework, and I hope to find a way to return the favor to CI producers and community)
[eluser]The Wizard[/eluser]
HELLO 1. the cannot modify header error is releated to something getthing echo'ed before the session or a redirect, anyway before something that puts out an 'header'. 2. in my case, it really didnt work sometime BUT i didnt notice, that sometimes i tryed on localhost and sometime's on the ip 127.0.0.1 which both point to the dev server but THEY ARE NOT THE SAME DOMAIN which for me, caused the session to fail "sometimes" could you check that and write us back? btw. i also tryed to load a model in a function, when i needed it, but it actually didnt work so i had to load it in the constructor, EVEN IF IT WAS NOT NEEDED IN ALL FUNCTIONS so there MIGHT be an issue with these at all. we will see
[eluser]Fierymind[/eluser]
well, the "sommtimes" failure drive me crazy, but here is some info in my case, may that help: - we do try this on live web server with live domain name - there is NO output before cookie/session work and I know what I'm talking about. here is the user/password verification function Code: function verifyUser($u,$pw){ if we put this function in model 'muser', and called it from 'user' controller like : Code: if (!$this->muser->verifyUser($_POST['username'],$_POST['password'])) it will "sometimes" fail to write the cookie but if I put the same function in controller 'user' itself and called it like Code: if (!$this->verifyUser($_POST['username'],$_POST['password'])) it works allllll the time. please note that session lib and all models are autoloaded.
[eluser]The Wizard[/eluser]
1. do you have some blank space AFTER a ?> <-- somewhere? 2. are you sure, you use 1 ADDRESS ONLY? like http://LOCALHOST OR http://127.0.0.1 ?
[eluser]majidmx[/eluser]
As herrkaleun pointed it out, it could be a cookie_domain problem. check your config file for Code: $config['cookie_domain']
[eluser]Fierymind[/eluser]
- I'm using live domain name, so there is no chance to use IP in mistake - I do not use ?> in any PHP file as of config file, I see I'm using the default setting Code: $config['cookie_domain'] = ""; but I never modified this before in any project AND I see software works great now after moving the session code in to the controller file with this value set to default .. If you really think $config['cookie_domain'] is that important, then I think CI must generate the value of it from $config['base_url'] or at least mention it as REQUIRED config item also, in config file: Code: /* | 'cookie_domain' = Set to .your-domain.com for site-wide cookies */ does that means, I have to use . infornt of domain ? to be like Code: $config['cookie_domain'] = ".something.com"; or this . is just a typo? |
Welcome Guest, Not a member yet? Register Sign In |