I encounter an issue using session insperl file i attached in jumi

How do you set a session in for the reason that page? after i use :

//this define and require I use from reading the other papers
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(__FILE__)));
define( 'DS', DIRECTORY_SEPARATOR );

require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');

$mainframe = JFactory::getApplication('site');
$session = &JFactory::getSession();

if(isset($_GET['id'])){ 
    var_dump($id= $_GET['id[i]']);
} else {echo "No session ";}

// code connect to db
// render out the items
//
foreach($rows as $i=>$row){ 
    $id[$i] = $row['rid'];
    $name[$i] = $row['rname'];

    $view .= '<tr>
                  <td>'.$id[$i].'</td>
                  <td><a href="http://www.thispage.php?id='.$id[$i].'">'.$name[$i].'</a></td>';
?>
}
<p><?php echo $view.'</tr></table>'; ?> </p>

......

It does not allow me to discover the sub-page of id=1 which i clicked on . What's the better way to cope with this type of factor? thanks.

You've got a syntax error do this prior to going any more:

</php
//this define and require I use from reading the other papers
define( '_JEXEC', 1 );
define('JPATH_BASE', dirname(dirname(__FILE__)));
define( 'DS', DIRECTORY_SEPARATOR );

require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');

$mainframe = JFactory::getApplication('site');
$session = &JFactory::getSession();

if(isset($_GET['id'])){ 
    var_dump($id= $_GET['id[i]']);
} else {
    echo "No session ";
}

// code connect to db
// render out the items
//
foreach($rows as $i=>$row){ 
    $id[$i] = $row['rid'];
    $name[$i] = $row['rname'];

    $view .= '<tr>
                  <td>'.$id[$i].'</td>
                  <td><a href="http://www.thispage.php?id='.$id[$i].'">'.$name[$i].'</a></td>';
}
?>
<p><?php echo $view.'</tr></table>'; ?></p>

Searching in the way Jumi includes PHP files, you can start with:

defined('_JEXEC') or die('Restricted access');

This can avoid the PHP file from being performed using a direct HTTP request (should you consider the example blogger file incorporated with Jumi you will notice this line). The define claims you've, initialise globals that Joomla! code uses to make certain a request has joined through your path.

Aside from that, as pointed out by @travega you close up from the PHP with ?> before you decide to close the foreach()