Hi , i have a problem with session variables.
The web site was already working correctly using sessions, i've had to
add a page which use a new variable session but this new one doesn't
get registered, so when the page redirect to another one the new
variable is vanished.
Here a snippet of the code:
<?php
unset($_SESSION['tipopreventivo ']);
//debug
$hand=fopen("pu blic/test.txt","w");
fwrite($hand,pr int_r($_POST,tr ue));
fclose($hand);
//
if(!empty($_POS T))
{
$error=array();
session_registe r('typep');
$_SESSION['type']=($_POST['type']?$_POST['type']:'Default');
//debug
$hand=fopen("pu blic/session.txt","w ");
fwrite($hand,pr int_r($_SESSION ,true));
fclose($hand);
//
if($_POST['info']==1)
{
$url="Location: prev.php";
header($url);
}
}
after submit text.txt e session.txt are right, in particular in
session.txt the variable $_SESSION['type'] is set ad has a value but
after the redirect to prev.php $_SESSION['type'] is not set
The sessions are working becouse other variables are passed correctly.
Any idea of what is wrong?
The web site was already working correctly using sessions, i've had to
add a page which use a new variable session but this new one doesn't
get registered, so when the page redirect to another one the new
variable is vanished.
Here a snippet of the code:
<?php
unset($_SESSION['tipopreventivo ']);
//debug
$hand=fopen("pu blic/test.txt","w");
fwrite($hand,pr int_r($_POST,tr ue));
fclose($hand);
//
if(!empty($_POS T))
{
$error=array();
session_registe r('typep');
$_SESSION['type']=($_POST['type']?$_POST['type']:'Default');
//debug
$hand=fopen("pu blic/session.txt","w ");
fwrite($hand,pr int_r($_SESSION ,true));
fclose($hand);
//
if($_POST['info']==1)
{
$url="Location: prev.php";
header($url);
}
}
after submit text.txt e session.txt are right, in particular in
session.txt the variable $_SESSION['type'] is set ad has a value but
after the redirect to prev.php $_SESSION['type'] is not set
The sessions are working becouse other variables are passed correctly.
Any idea of what is wrong?
Comment