This question already has an answer here:
- How to fix “Headers already sent” error in PHP 11 answers
I am having an issue with session_start()
. It is creating a new session every refresh/load of the page.
here is the code:
<?php
$bob = session_id();
echo "Session ID on load is ".$bob;
echo "<br>";
if($bob==""){
session_start();
$bob = session_id();
echo ' session ID currently is '.$bob;
}
// a bunch more stuff
when i load the page, I get the following:
Session ID on load is session ID is currently ed320bc5e24c871c9db8ea30e6796c14 (or a variant)
if I refresh the page i get:
Session ID on load is session ID is currently fbd69d01d511a7be382799dca7279a86 (or a variant)
the session Id is always blank before session_start()
is called and it is always a new session_id()
It does this in all browsers and I have checked to make sure cookies are turned on.
the session save path is given as /tmp
. I am not sure exactly where that is, but looking through my root and all other directories, I can't find a session file (assuming it would look something like sess_fbd69d01d511a7be382799dca7279a86).
So I am thinking there is something going on with the save path, but am too new at this to know for sure, and the server admins are being fairly unhelpful. What should my next steps at diagnosing the issue be? The server is running 5.3.22.
phpinfo is here
Thanks for any help.
ps you can visit pcm.pcmxa.com to see the issue for yourself if you wish.