[thelist] php $_SESSION

Sven Göttner lists at goettner.de
Wed Oct 16 18:39:00 CDT 2002

> Hmmm are you trying to say, if session_uname isnt set, and if it is set
> that it doesn't equal $user?
> if (!isset($_SESSION['SESSION_UNAME']) || $_SESSION['SESSION_UNAME'] !=$user))

No, ($_SESSION['SESSION_UNAME'] != $user) is enough.

Since if $_SESSION['SESSION_UNAME'] isn't set at all,
it definitely can't be $user, so with this check you definitely
get false in both cases (not set or not $user).

This works except you want go different ways in the script for
each case, e.g. make the user register if $_SESSION['SESSION_UNAME'] isn't
set at all ( !isset() ) OR e.g. give an error message if $_SESSION['SESSION_UNAME']
IS set, but doesn't have the correct value, which would be $user.

Again: isset() just checks if the VARIABLE exists, it DOES NOT concern about its VALUE.
On the other hand, if you want ( $_SESSION['SESSION_UNAME'] == $user ) to return true,
$_SESSION['SESSION_UNAME'] NEEDS to be set AND have the value $user.

Hope I'm helping,


More information about the thelist mailing list