I am trying to implement the logout procedure for my website.
When the user clicks the sign out button I redirect him to the following home controller script.
http : // mydomain/php/ci/index.php/index/?logout=set
And in my home controller index function I check if logout=set then destroy all sessions.
echo @$_GET['logout'];
exit();
if(@$_GET['logout'] == "set")
{
unset($_SESSION['userid']);
@$_SESSION = array();
@session_unset();
@session_destroy();
}
But when I reach here nothing gets printed because the logout param is not passing.
I see the following url when i get here on clicking the sign out button.
http://localhost/php/ci/home/
Why is this happening?
You can get all the
getdata withCodeIgniterlike this:However, don’t use the
indexmethod to log users out, but make a method for it, like i.e. this:Then in your view make a link like this:
You will want to use the CodeIgniter session handler for this, but this is just a quick solution for your problem. I can advice you to read the CodeIgniter manual. As your “solution” for logging out is quite dirty and does not fit the MVC principle