Q:

jquery & php + if session is dead an error is returned

I've noticed if the session is dead (on an Jquery AJAX PHP Request) the data returned is preceeded with an error message if the session is needed in the request.
How do other sites deal with this?
Similar code is shown below - eg: its using a SESSION variable in the code which doesn't exist as the session is dead.
public function internal($variable) {
    if($_SESSION['data'] == $variable) {
           echo TRUE;        
        }else{
           echo FALSE;
        }
}

Should I use isset to check if the variable exists? 
Should I be coding for dead sessions?
thx

A:

You need to add the isset also:
public function internal($variable) {
    if(isset($_SESSION['data']) && $_SESSION['data'] == $variable) { //add here
           echo TRUE;        
    }else{
           echo FALSE;
    }
}

