需要刷新页面才能删除会话

In this code I'm trying to ban client if he/she/it doing to much(10) login request for 3 minutes. The problem is after 3 minutes user must refresh the page 2 times. I can see the reason why it's enter into if statement but I can't find the solution. I feel like I've overcoded.

if($this->sessions->get_data("wrong_login")>10){
            if(!isset($_SESSION["ban_time"])){
                $this->sessions->set_data("ban_time", time());
            }else
            {
                if(time() - $this->sessions->get_data("ban_time") > 180){ // 180 seconds
                    $this->sessions->remove("ban_time");
                    $this->sessions->remove("wrong_login");
                }
            }

            // The message if user still banned
            die("Banned for 3 minutes!");
        }

I hope I can tell the problem..

EDIT: This code is the inside of the construct of register controller.

Before your IF statement, add another if statement that checks for ban_time session if the time is up, then set the wrong_login session to 0 if it is.

if($this->sessions->get_data("ban_time") < time())
{
    $this->sessions->remove("ban_time");
    $this->sessions->set_data("wrong_login", 0);
}

remove your else statement there.

also forgot to mention! when you set the ban time, it should be time() + 180.

if(!isset($_SESSION["ban_time"])){
    $this->sessions->set_data("ban_time", time()+180);
}

use header function.

e.g.

header("Location: /path/to/some/file.php?error=Banned for 3 minutes.");

Then on the file.php you can do this:

<?php

// Parse error
$error = isset($_GET['error']) ? $_GET['error'] : '';

// Display error (if any) and stop executing the rest of the code.
if (!empty($error)) {
    exit($error);
}

?>

This will not work if you already started to output...