Trouble with Session var
| From: | James Johnson | Date: | Sat, 02 Aug 2003 23:18:54 +0000 |
| Subject: | Trouble with Session var | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-158058@lists.php.net to get a copy of this message | ||
Hello,
This one has me stumped.
I'm setting a session var to a value returned from a query, then redirecting
to another page. I get the following error on the second page:
Notice: Undefined index: sv_adCatText
On the page that sets the session var, I can do an echo of
$HTTP_SESSION_VARS['sv_adCatText'] and it prints the var fine. If I do a
var_dump($HTTP_SESSION_VARS); I can see all of the session vars, except this
one.
Is there a limit or something to the number of Session vars that can be
used? I've even tried setting a Session var called "foo" and that doesn't
work.
Thanks,
James
Here's the code:
First Page:
<?php session_start();?>
<?php
if(isset($_POST['selCat'])){
$as_adCat =
addslashes($_POST['selCat']);$HTTP_SESSION_VARS['sv_adCat'] =
trim($as_adCat);
$id = $_POST['selCat'];
mysql_select_db($database_CCB, $CCB);
$query_GetCatText = "SELECT category FROM categories WHERE
category_id = '$id' ORDER BY category ASC";
$GetCatText = mysql_query($query_GetCatText, $CCB) or
die(mysql_error());
$row_GetCatText= mysql_fetch_assoc($GetCatText);
$HTTP_SESSION_VARS['sv_adCatText'] = $row_GetCatText['category'];
if($HTTP_SESSION_VARS['sv_adCatText'] == "Books"){
header("Location: " . "CreateAdBook.php");
exit;
}else{
header("Location: " . "CreateAdNonBook.php");
exit;
}
}
?>
Second Page:
<?php session_start();?>
<td><?php echo $HTTP_SESSION_VARS['sv_adCatText']; ?></td>