Page 1 of 1

unsetting a $_SESSION variable

Posted: Mon Aug 23, 2004 4:56 pm
by Headup
This question probably sounds really stupid, but...

When you unset a $_SESSION variable, does its value change to ""?

And if I wanted to write an IF statement based on it being unset, would i use:

Code: Select all

if($_SESSION[user] != "")
I'm sorry for the stupidity of this question, but I've been working on a set of three pages for the past day; I'm tired, I'm hungry, and I can't think straight anymore.

Posted: Mon Aug 23, 2004 5:01 pm
by tim
the value is 0/not able to be returned

I would use empty() or isset() to check for the var being present, example:

Code: Select all

<?php
if (isset($_SESSION['user'])) {
// is present
} else {
// not present
}
?>