Page 1 of 1

clearing a session variable

Posted: Tue Jul 01, 2003 11:44 am
by gurjit
i have a session array which i declare like this

Code: Select all

<?php
session_register("stuid_list");
?>
i then later add numbers to the session variable making it an array like this:

Code: Select all

<?php
$stuid_list[] = "$sib_stuid";
?>
1. how do i clear the session variable? i have other sessions in the program, so i cannot use destroy(). i just want to clear the session values in stuid_list.
i tried

Code: Select all

<?php
session_unregister("stuid_list");
?>
but it never worked

Posted: Tue Jul 01, 2003 12:24 pm
by phice
Do you have PHP 4.2+ installed? If so, you can use this example:

Code: Select all

<?php
session_start();

// Create session variable
$_SESSION["var1"] = "the value";

// return the variable
echo $_SESSION["var1"];
// returns: the value

// empty the variable
$_SESSION["var1"] = "";

// return the variable
echo $_SESSION["var1"];
// returns: 

?>

Hope this helps.