Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing Session Variable 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
If I have this:

$_SESSION['DB6'] = $_POST['DB6']

Then how do I do this:

$_SESSION['DB6'] = ""

or

$_SESSION['DB6'] = 0

Regards
 
Many thanks sleipner, will try that, only problem then is can I check for the variable $_SESSION['DB6'] not being there when I produce a documented list of variables and their values if greater then 0 or "".

At the moment I do this:

if ($_SESSION['DB6']>0) {
echo "Fuji Digital Betacam DBC-6 Qty =".$_SESSION['DB6']."<br>\n";
}
if ($_SESSION['DB12']>0) {
echo "Fuji Digital Betacam DBC-12 Qty =".$_SESSION['DB12']."<br>\n";
}

Which is an orderly list.

Many thanks
 
if you have done an unset() on a variable and you then reference that variable in a condition as you are doing here:

if ($_SESSION['DB6']>0) {

then PHP will generate a warning about the fact that the array index no longer exists.

When I'm checking for the existence or non-existence of a variable I use isset():

if (isset($_SESSION['DB6'])) {

or array_key_exists():

if (array_key_exists('DB6', $_SESSION)) {


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks very much sleipnir, just what I wanted, another star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top