Page 1 of 1

Session values not being stored.

Posted: Mon Dec 18, 2006 8:26 am
by impulse()
I noticed a couple of days ago that 2 of my scripts weren't working that heavily rely on sessions. I did some debugging by creating another session variable assigning it with the value 1 and then increment it by 1 on each visit. That seemed to work fine and then my other scripts started working again. I thought problem solved until the same thing happened last night and as soon as I created another session variable with the value 1 and incremented it once, the other scripts started working again. Now the same thing has happened now but I haven't assigned a value to my test session variable because I was hoping someone has come across this problem before and can run some diagnostics with me to solve the problem.
I can post code of my 2 scripts that aren't working but they're a couple of hundred lines long and I don't want to spam the board. If you need to see them though let me know.

Regards,

Posted: Mon Dec 18, 2006 10:45 am
by Kieran Huggins
The only thing that comes to mind is that you're not calling session_start() before your output starts (session_start() adds headers), and that by assigning a $_SESSION variable you're implicitly calling it early enough.

Try moving session_start() to the very first line in your script, maybe by using auto_prepend_file.

Cheers,
Kieran

Posted: Mon Dec 18, 2006 12:29 pm
by impulse()
That was already the case. It seems more server related than a script problem because it's 2 different scripts that use sessions stop and start working at the same time when I have the problems.

Posted: Mon Dec 18, 2006 1:07 pm
by Kieran Huggins
try setting

Code: Select all

error_reporting(E_ALL);
and see if you get warnings when it fails

Cheers,
Kieran

Posted: Thu Jan 11, 2007 8:11 pm
by impulse()
Kieran Huggins wrote:The only thing that comes to mind is that you're not calling session_start() before your output starts (session_start() adds headers), and that by assigning a $_SESSION variable you're implicitly calling it early enough.

Try moving session_start() to the very first line in your script, maybe by using auto_prepend_file.

Cheers,
Kieran

It's taken me a while to solve this problem, and looking back on this post now, Keiran_Huggins had solved the problem and I hadn't noticed :)

Anyway, you were correct. I had 1 line before it to start a form and then started the session on the second line.

Posted: Thu Jan 11, 2007 8:45 pm
by Kieran Huggins
Well aren't I just a smarty pants!