Logout function using PHP PDO Object-oriented

Asked

Viewed 390 times

2

I have a big problem with the function of displacing the panel, I made a public Function Logout()

Filing cabinet Login.class.php:

public function Logout(){
    if($this->isLogged()) {
        unset($_SESSION[$this->prefix.['email']]);
        unset($_SESSION[$this->prefix.['password']]);
        session_destroy();

        return true;
    } else {
        return false;
    }
}

And in my file panel.php is like this:

session_start();
$Logins = new Logins();
if (!$Logins->isLogged()) {
    header("Location: ?pag=login");
} else {}
if(isset($_GET['action']) == 'logout') {
    if($Logins->Logout()) {
        header("Location: ?pag=login");
    }
}

Now that I’m having problems, I’m exactly 8 hours stuck in it, when I click Logout it goes back to home.php but the Session does not destroy, nothing happens. What I am doing wrong?

  • 1

    There must be a syntax error in unset($_SESSION[$this->prefix.['email']]) and unset($_SESSION[$this->prefix.['password']]), because of . after prefix.

  • Opa I fixed, but nothing was solved yet, it was like this now unset($_SESSION[$this->prefix.'email']); unset($_SESSION[$this->prefix.'password']);

  • I left like you said and still nothing... :'(

  • What is prefix? whether that information is in a Session try to access it like this: unset($_SESSION['email']); and unset($_SESSION['password']);

  • prefix is a parameter configuration that I made, for me to change the name of session When I find it necessary, you understand? Yes I’ve tried this way too but nothing I still think I must be doing something wrong and pretty ugly yet rsrs. :'(

  • 2

    Vish. How do you guard the e-mail and the password in Session?

  • Well, my code is very long so I’ll put it on Pastebin http://pastebin.com/hNbbQdFE

  • Little suggestion: $_SESSION[$this->name]['email'] would not be better than using the prefix?

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.