PDA

View Full Version : session id variable is input twice ??


songboy
02-14-2011, 03:23 PM
I'm checking things through and I've hit this odd problem. On one page I use this to create a session id variable:
if(!isset($_SESSION))
{
session_start();
}
include("conn.php");
$PHPSESSID = session_id();
@$sess_id = $PHPSESSID;
$query = sprintf("INSERT INTO submit_check (session_id)values('$sess_id')");
mysqli_query($cxn,$query) or die (mysqli_error($cxn));

$_SESSION['sess_id'] = $sess_id;

When I check the PHP myAdmin, one hashed id has been stored in the table.
However, (and this is the odd thing) in another section I use the following:
if(!isset($_SESSION))
{
session_start();
}
include("conn.php");
$PHPSESSID = session_id();
@$sess_id_vis_logged = $PHPSESSID;
$query = sprintf("INSERT INTO submit_check (session_id)values('$sess_id_vis_logged')");
mysqli_query($cxn,$query) or die (mysqli_error($cxn));

$_SESSION['sess_id_vis_logged'] = $sess_id_vis_logged;
When this script is activated, I end up with two identical hashed entries in the data table.
The problem is that the codes are structured identically. I have no idea why the second should create two identical ids. I've looked through the scripts and I'm not finding any extra includes etc or anything that should prompt the second code extract to duplicate the session variable.
Any pointers would be gratefully received.
Songboy

songboy
02-14-2011, 04:00 PM
Sorry folks, it seems it is something to do with an include. What's happening is I have a 'switch' script which does not seem to be stopping at the 'break' command. I have two includes (one before the break and one after) both calling the same page which subsequently creates two identical session ids.
How is it crashing through the 'break' ? Is it a curly brace thing ?
Sorry for the time-wasting !
Songboy

edbr
02-15-2011, 12:36 AM
no prob done it lots of times also