Sign Out

I am trying to create a codeigniter login / logout page. My problem is that when I exit the webpage, they redirect me to the login page. When I return, I get a page that says:

Document Validity

This document is no longer available. 

But when I refresh this page, I get into the system again (oO)

The following codes contain my constructors and exit functions. Please help me create the perfect login page.

 function __construct() { parent::__construct(); $this->load->model('user_model'); $this->output->set_header('Last-Modified: ' . gmdate("D, d MYH:i:s") . ' GMT'); $this->output->set_header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); $this->output->set_header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); } function logout() { $newdata = array( 'user_name' =>'', 'user_email' => '', 'logged_in' => FALSE, ); $this->session->unset_userdata($newdata); $this->session->sess_destroy(); redirect('default_controller','refresh'); } 

I tried to find the correct exit method, but I can’t.

+4
source share
3 answers

try just like this:

 function logout() { $user_data = $this->session->all_userdata(); foreach ($user_data as $key => $value) { if ($key != 'session_id' && $key != 'ip_address' && $key != 'user_agent' && $key != 'last_activity') { $this->session->unset_userdata($key); } } $this->session->sess_destroy(); redirect('default_controller'); } 
+15
source

no need to use this line

$ this-> session-> sess_destroy ();

+1
source
 public function Logout() { $this->session->sess_destroy(); redirect('login'); } /** Here ('login') is controller class . In view ('logout-page'):-**/ <a href="home/logout">Logout</a> 
0
source

Source: https://habr.com/ru/post/1498769/


All Articles