[eluser]esenes[/eluser]
hi,am developing a login system with session,in that am registering the user information in session and destroying it while clicking logout all working right untill this..but in browser back button are enabled,and if i navigate with those buttons after logout those pages are still enabled how to disable that?
my code:
controllers:
clogin1.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class clogin1 extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper(array('url','form','jquery'));
$this->load->library('session');
}
function index()
{
if (($this->session->userdata('uname') == "") && ($this->session->userdata('upass') == "") )
{
$this->load->view('login');
$submit = $this->input->post('submit');
if ( $submit != FALSE)
{
$uname = $this->input->post('uname');
$upass = $this->input->post('upass');
$this->authorize($uname,$upass);
}
}
else
{
redirect('chome','refresh');
}
}
function authorize($uname,$upass)
{
if($this->checkdb($uname,$upass) == FALSE)
{
redirect('clogerr');
}
else
{
$cistartdata = array(
'uname' => $uname,
'upass' => $upass,
'logged_in' => TRUE
);
$this->session->set_userdata($cistartdata);
redirect('chome','refresh');
}
}
function checkdb($uname,$pass)
{
$this->db->select('*');
$this->db->from('users');
$this->db->where('uname',$uname);
$this->db->where('upass',$pass);
$query = $this->db->get();
if($query->num_rows() == 1)
{
//$this->load->view('index');
return TRUE;
}
else
{
//$this->load->view('login');
return FALSE;
//echo "unsuccessfull";
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
?>
chome.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class chome extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper(array('url','form','jquery'));
$this->load->library('session');
//$this->load->library('encrypt');
}
function index()
{
if (($this->session->userdata('uname') != "") && ($this->session->userdata('upass') != "") )
{
$this->load->view('home');
}
else
{
redirect('clogin1');
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
?>
cpage1.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class cpage1 extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->helper(array('url','form','jquery'));
$this->load->library('session');
//$this->load->library('encrypt');
}
function index()
{
if (($this->session->userdata('uname') != "") && ($this->session->userdata('upass') != "") )
{
$this->load->view('page1');
}
else
{
redirect('clogin1');
}
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
?>