Page 1 of 1

SID problem

Posted: Thu Mar 24, 2005 8:02 am
by AGISB
I got following code

Code: Select all

session_start();
$sess = session_id();
if (!ereg("(^([a-f0-9]{32})$)", $sess)) {
	session_regenerate_id();
}
$sid_id = strip_tags(SID);
if (!empty($sid_id) ) {
	$s_add = "?".$sid_id;
} else {
	$s_add = "";
}
This leads to the following. If the browser opens a session first time it apparently gets a SID even though cockies are enabled. So it places $s_add behind all links. When the next page is called the url part is gone and all works fine.
This does not limit the site functionality but it does bother me.

Anyone got an idea how to avoid this?

Posted: Thu Mar 24, 2005 8:39 am
by feyd
I'd imagine trans_sid is on..

I think the following should tell you.

Code: Select all

echo 'session.trans_sid is ' . (ini_get('session.trans_sid') == 1 ? 'on' : 'off');

Posted: Thu Mar 24, 2005 11:18 am
by AGISB
Trans ID is off. The above coding places the sid into the URL manually when cockies are off. Well as I said it does it on the first site call whether cockies are off or on.

I probably use a session var and session_regenerate_id to get around this.

Posted: Thu Mar 24, 2005 11:25 am
by AGISB

Code: Select all

if ($_SESSION['status'] <> 'on') {
	$_SESSION['status'] = 'on';
	session_regenerate_id();
}
not even this gets me to solve this problem. Very weird

Posted: Thu Mar 24, 2005 11:29 am
by feyd
basically it has to though.. because the server won't know if cookies are on until the second page request..