You are using two kinds of checks in your control structure: isset and ==. I believe in this case the isset is what's causing your error whenever variable $i has not been initialized.
Code:
if($i && $i=="logout") {
would be the extended illustration of (perhaps) what you are trying to do. In practice,
would have the desired result. Not only must $i have been initialized, but it also must have the value "logout". If $i is neither, it won't match.