Skip to content

Commit

Permalink
Merge pull request #86 from amirsanni/session-destroy
Browse files Browse the repository at this point in the history
Use php inbuilt function for destroying session
  • Loading branch information
amirsanni committed Sep 25, 2021
2 parents 75f51d7 + 14e26bb commit 8a55959
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions application/controllers/Logout.php
Expand Up @@ -18,23 +18,7 @@ public function __construct()

public function index()
{
$this->session->sess_destroy();

/*
* unset all cookies
* Thanks to http://stackoverflow.com/questions/2310558/how-to-delete-all-cookies-of-my-website-in-php
*/
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach ($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time() - 1000);
setcookie($name, '', time() - 1000, '/');
}
}

session_write_close();
session_destroy();

redirect(base_url());
}
Expand Down

0 comments on commit 8a55959

Please sign in to comment.