session id changes on every page refresh

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eshban
Forum Contributor
Posts: 184
Joined: Mon Sep 05, 2005 1:38 am

session id changes on every page refresh

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

Re: session id changes on every page refresh

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