Page 1 of 1

Error retrieving session variables

Posted: Fri Dec 27, 2002 9:48 am
by feiticeir0
Hi,

i'm developing a kind of a project in school, and i need to pass variables from one page to another.

i've tried to do this, passing the session to the other page

<td width="15%"><a href="alterar.php?PHPSESSID=<?php $HTTP_SESSION_VARS["idempregado"]?>">Alterar</a></td></tr>

the problem is that, in the other page,
i got the same value. the variables are not the same, the value is not the same, but the result is the same.

i register the variable that i want to pass as a session variable

if ($_POST[escolha]) {
$idempregado = $_POST[idempregado];
session_register ("idempregado");
ver_caracteristicas ($idempregado);

the problem is that i get the same value for the two variables

$var = $_SESSION[idempregado];
$var2 = $_SESSION[idadministrador];


how to do ?

regards

Posted: Fri Dec 27, 2002 3:00 pm
by oldtimer
So where are you getting the $var2 = $_SESSION[idadministrador];


You should just be able to do

Code: Select all

<?php
session_register ("idempregado", "idadministrador"); 


?>
And then on every page have the session_start(); and you can pass that information along.

I have a pretty long one for one of my sites.

Code: Select all

<?php

   session_register("valid_user", "user","email", "url", "twgs", "level", "id", "sitename", "canpost");


?>

Posted: Fri Dec 27, 2002 4:59 pm
by evilcoder
just being picky here, but its good practice to use single quotes when define $_SESSION and $_POST variables, eg:

$_POST['Whatever'] instead of $_POST[Whatever]
$_SESSION['Likewise']

:lol: