Fatal error while using isset

2

I have a code that is giving error and I can not fix it. The snippet of the file giving error is this:

if(isset(!($_SESSION['username']) && ($_COOKIE['remember'] == "remember"))){

$cname = FilterText($_COOKIE['rusername']);
$cpass_hash = $_COOKIE['rpassword'];


$csql = mysql_query("SELECT password,id FROM users WHERE username = '".$cname."' LIMIT 1") or die(mysql_error());
$cnum = mysql_num_rows($csql);

    if($cnum < 1){
        setcookie("remember", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
        setcookie("rusername", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
        setcookie("rpassword", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
    } else {

        $crow = mysql_fetch_assoc($csql);
        $correct_pass = $crow['password'];

        if($cpass_hash == $correct_pass){
            $_SESSION['username'] = $cname;
            $_SESSION['password'] = $crow['password'];
            $sql3 = mysql_query("UPDATE users SET ip_last = '".$remote_ip."' WHERE username = '".$cname."'");
            header("location: me"); exit;
        } else {

            setcookie("remember", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
            setcookie("rusername", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
            setcookie("rpassword", "", time()-60*60*24*100, "/"); setcookie("cookpass", "", time()-60*60*24*100, "/");
        }
    }
}

And the error is as follows:

  

Fatal error: Can not use isset () on the result of an expression (you can use "null! == expression" instead)

    
asked by anonymous 07.09.2014 / 03:36

1 answer

3

The error says that you can not use isset () with the return of something, in case the code below the value of $_SESSION['username'] is denied and this is the value passed to isset ().

if(isset(!($_SESSION['username'])

Modify your code to:

if(!isset($_SESSION['username']) && ($_COOKIE['remember'] == "remember")){
    
07.09.2014 / 03:53