
Originally Posted by
HardCoded
So let's have a look at the session code. All you usually need is session_start();, which will handle everything.
Hi,
I have been done a test: The variable "VAR" has been set as a session variable which value should be reached in body.php. I have had no sucess with the following codes.
Index.php:
Code:
<?php
// re/initialize session
if ( (!$_GET["PHPSESSID"]) && (!session_id()) )
{
session_start();
}
else
{
// this ID is sent back to index.php by other
// site page
session_id( $_GET["PHPSESSID"] );
session_start();
}
// It is a test and I should get VAR value
// in body.php.
//session_register( "VAR", "TESTE");
$_SESSION["VAR"]="TESTE";
// propagate session ID to come back to index
// this ID is used for propagation
$sid = "PHPSESSID=" . session_id();
//echo( $sid ) ;
?>
<!------------------------------------------------------------------------------
RHER
Consultoria e desenvolvimento
RHER.com v0.1
index.php
Pagina de indice do site
Data Autor Evento
26-01-2004 Rodrigo Criacao
//----------------------------------------------------------------------------->
<?php
// requisicoes
require( "./define.php" );
require( "./php/auth.php" );
// obtencao dos parametros
$body = $_GET[ "body" ];
$topic = $_GET[ "topic" ];
$div = $_GET[ "div" ];
$action= $_GET[ "action" ];
//
// dados de formulários
//
// os dados vindos pelo método POST
// são armazenados nessa variável.
// Como o post do formulário chega
// à página index.php, os dados são
// repassados mediante o parâmetro
// 'postdata' e método get.
// Como convencão, todos os dados de
// quaisquer que sejam os formulários
// devem estar no array 'postdata'.
// Ex: para um input do form -> name='postdata[campo_01]'
//
$postdata = expandPostData($_POST["postdata"]);
if ($body == '')
$body = "home";
?>
<html>
<head>
<title>RHER Consultoria e desenvolvimento</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content=".">
<meta name="keywords" content="." >
</head>
<link type="css/text" src="/css/common.css">
<body bgcolor="#dfdfdf" >
<table height="100%" width="100%" valign=top align=center border=0 >
<tr><td valign=top>
<div align=center valign=top>
<div class=conteudo align=center>
<table height="400" width="770" valign=top align=center border=0 bgcolor="#dfdfdf" cellpadding=0 cellspacing=0>
<tr>
<td colspan=2>
<table width="770" valign=top align=center border=0 cellpadding=0 cellspacing=0 bgcolor="#FFFFFF" >
<tr height=60 width=770>
<td align=center height=60 valign=middle colspan=2>
<?php include "$sUrl/header/header.php?action=show$sid" ?>
</td>
</tr>
<tr height=20 width=770>
<td align=center height=20 valign=middle colspan=2 width=770>
<?php include "$sUrl/menu/menu.php?action=show$sid" ?>
</td>
</tr>
<tr height=400 width=770>
<td align=center valign=middle width=200 >
<?php include "$sUrl/side/side.php?$sid&body=$body&topic=$topic&div=$div&action=$action" ?>
</td>
<td align=center valign=top width=570>
<?php include "$sUrl/body/body.php?$sid&body=$body&topic=$topic&div=$div&postdata=$postdata&action=$action" ?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width=200 valign=top>[img]/images/footer_left.gif[/img]</td>
<td align=center height="26" valign=middle width=570>
<table valign=middle align=center border=0 cellpadding=0 cellspacing=0 width=570>
<tr>
<td bgcolor=#AEC1E7 width=550>
<?php include "$sUrl/footer/footer.php?action=show" ?>
</td>
<td valign=top width=20>[img]/images/footer_right.gif[/img]</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</td></tr></table>
<?php //echo("$body
$topic
$div
$postdata"); ?>
</body>
</html>
The body.php, a direct page called by index.php is:
<?php
// re/initialize session
//session_id($_GET["PHPSESSID"]);
//session_start();
echo("
BODY:".$_GET["PHPSESSID"]);
echo("
BODY:".session_id());
// VAR value is set in index.php
echo("
BODY:".$_SESSION["VAR"]);
?>
<?php
// requisicoes
require( "../define.php" );
require( "../php/functions.php" );
// obtencao dos parametros
$body = $_GET[ "body" ];
$topic = $_GET[ "topic" ];
$action = $_GET[ "action" ];
$div = $_GET[ "div" ];
$postdata = urlencode( $_GET[ "postdata" ] );
?>
<table width=570 height=400 valign=top align=center border=0 cellpadding=10 cellspacing=0>
<!--<tr align=right width=500 valign=top>
<td height=10></td>
</tr>
-->
<tr align=right width=500 valign=top>
<td height=20>
<font class=data><?php data(); ?>.</font>
</td>
</tr>
<tr align=center width=500 valign=top height=200>
<td>
<?php include "$sUrl/$body/$body.php?body=$body&topic=$topic&div=$div&action= $action&postdata=$postdata$sid" ?>
</td>
</tr>
</table>
<?php //echo("$body
$topic
$div
$postdata"); ?>