Page 1 of 1
session questions
Posted: Thu May 29, 2008 1:07 am
by deeessay
There is a page in my site, that when i don't put session_start (), session variables will be undefined. but when i put session_start (), this error message will appear:
Notice: A session had already been started - ignoring session_start()
aaaaaaaarrrrrgggghhhh!!!! this one is driving me nuts!!!

Re: session questions
Posted: Thu May 29, 2008 2:29 pm
by califdon
Are you sure that you don't have a session_start(); statement somewhere else in that script? Have you checked, using Find?
Re: session questions
Posted: Thu May 29, 2008 10:58 pm
by deeessay
the page i was referring to is actually an included page in another page that has a session_start....
anyways, i think i found the problem.... that included page was brought by ajax.... is there a chance that the session_start is lost after ajax has loaded the page?
Re: session questions
Posted: Thu May 29, 2008 11:15 pm
by califdon
deeessay wrote:the page i was referring to is actually an included page in another page that has a session_start....
That explains it then. When php "includes" a file, it just inserts the contents, so you had two session_start()'s, which is what the error message was telling you.
anyways, i think i found the problem.... that included page was brought by ajax.... is there a chance that the session_start is lost after ajax has loaded the page?
I'm not sure what you mean. Ajax doesn't load a page, it merely returns data to the page that's already loaded. If the php script that Ajax calls needs to use session variables, it will need to have session_start(), too, but that has nothing to do with the page that was previously loaded.
Re: session questions
Posted: Thu May 29, 2008 11:26 pm
by ashebrian
I've had the same prblem as that. All i did was hide the error. this isn't really an error as the page and its contents will still work as asked to do so
Re: session questions
Posted: Fri May 30, 2008 12:31 am
by deeessay
yeah that's what I did too, i just hid the notice.... it's just a notice anyway. and i think it just ignores the extra session_start();
You just don't have a choice if you don't include the session_start, session variables are undefined. If you include it, then it's redundant.... damned if you do damned if you don't.
