smetterd
asked on
Can't get session variable to stick!
Can't get session variable to stick!
<?php
if (!isset($_SESSION)) {
session_start();
}
if($_GET['detail'] == 0){
(($_SESSION['detail'])==0) ;
} elseif($_GET['detail'] ==1){
(($_SESSION['detail'])==1) ;
}else {
echo "ERROR";
}
?>
sessionDetail is <?php echo $_SESSION['detail']; ?><br>
getDetail is <?php echo $_GET['detail']; ?><br>
httpReferrer is <?php echo $_SERVER['HTTP_REFERER']; ?>
-----
Returns:
----
sessionDetail is
getDetail is 1
httpReferrer is http://elearn.sbcisd.net/walkthrough/inc_palm_menu.php
<?php
if (!isset($_SESSION)) {
session_start();
}
if($_GET['detail'] == 0){
(($_SESSION['detail'])==0)
} elseif($_GET['detail'] ==1){
(($_SESSION['detail'])==1)
}else {
echo "ERROR";
}
?>
sessionDetail is <?php echo $_SESSION['detail']; ?><br>
getDetail is <?php echo $_GET['detail']; ?><br>
httpReferrer is <?php echo $_SERVER['HTTP_REFERER']; ?>
-----
Returns:
----
sessionDetail is
getDetail is 1
httpReferrer is http://elearn.sbcisd.net/walkthrough/inc_palm_menu.php
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also needed to remove the unnecessary quotes around SESSION... They were causing an error
The following code works perfectly. Thanks!
<?php
if (!isset($_SESSION)) {
session_start();
}
if($_GET['detail'] == 0){
($_SESSION['detail']=0);
} elseif($_GET['detail'] ==1){
($_SESSION['detail']=1);
}else {
echo "ERROR";
}
?>
sessionDetail is <?php echo $_SESSION['detail']; ?><br>
getDetail is <?php echo $_GET['detail']; ?><br>
httpReferrer is <?php echo $_SERVER['HTTP_REFERER']; ?>
The following code works perfectly. Thanks!
<?php
if (!isset($_SESSION)) {
session_start();
}
if($_GET['detail'] == 0){
($_SESSION['detail']=0);
} elseif($_GET['detail'] ==1){
($_SESSION['detail']=1);
}else {
echo "ERROR";
}
?>
sessionDetail is <?php echo $_SESSION['detail']; ?><br>
getDetail is <?php echo $_GET['detail']; ?><br>
httpReferrer is <?php echo $_SERVER['HTTP_REFERER']; ?>
<?php
session_start();
if (!isset($_SESSION)) {
session_start();
}
...