Welcome Guest, Not a member yet? Register   Sign In
login - session issue
#1

[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 */
?>
#2

[eluser]InsiteFX[/eluser]
Pleas use code tags, if you do not know how to use code tags then use POST REPLY.

This is caused by your browser caching your web pages.

For one add refresh to redirects.
Code:
redirect('clogin1');
//should be
redirect('clogin1', 'refresh');

Place in your html <head> </head> tags
Code:
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">

InsiteFX
#3

[eluser]esenes[/eluser]
:coolsmile: thanks a lot..its working now....




Theme © iAndrew 2016 - Forum software by © MyBB