session questions

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
deeessay
Forum Commoner
Posts: 55
Joined: Sat May 24, 2008 1:02 am

session questions

Post 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!!! :banghead:
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: session questions

Post by califdon »

Are you sure that you don't have a session_start(); statement somewhere else in that script? Have you checked, using Find?
User avatar
deeessay
Forum Commoner
Posts: 55
Joined: Sat May 24, 2008 1:02 am

Re: session questions

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: session questions

Post 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.
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

Re: session questions

Post 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
User avatar
deeessay
Forum Commoner
Posts: 55
Joined: Sat May 24, 2008 1:02 am

Re: session questions

Post 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. :crazy:
Post Reply