Page 1 of 1

session id changes on every page refresh

Posted: Fri Feb 08, 2008 2:11 am
by eshban
I have just start a session in my website. But on every page refresh i got a different session id. Here is the code

Code: Select all

 
if(!session_id())
{
session_start();
}
print session_id();
 
I am using Xampp server, can anyone tell me that whcih session property i will set in my php.ini file so that my session id will not changed on every page refresh

Thanks

Re: session id changes on every page refresh

Posted: Fri Feb 08, 2008 12:47 pm
by califdon
eshban wrote:I have just start a session in my website. But on every page refresh i got a different session id. Here is the code

Code: Select all

 
if(!session_id())
{
session_start();
}
print session_id();
 
I am using Xampp server, can anyone tell me that whcih session property i will set in my php.ini file so that my session id will not changed on every page refresh

Thanks
Don't put session_start() in a conditional--it must be there EVERY time. Check documentation.