Welcome Guest, Not a member yet? Register   Sign In
Check for Login on Each Function?
#21

[eluser]Tom Glover[/eluser]
[quote author="Edemilson Lima" date="1201968433"]Instead of using:

Code:
header("Location: $no_access");

Use the right CI function:

Code:
redirect('/login/form/');

Quote:I posted an auto protect user library in ignited code, it validates user credentials on every page load.

I did try to find it, but is hard without the thread name... Can you post the link here for us?[/quote]


Thanks i did use the CI way in the Variable.
#22

[eluser]Carl_A[/eluser]
Hi,
Im new to Codeigniter.
Im making a user login page, and i wanted to check for inactivity

Forexample, I create a new session using the session class when the user has properly logged in

Code:
class User extends Controller{
  
   function User()
    {
        parent::Controller();
        $this->load->helper('form');
        $this->load->helper('url');
        
    }
   function index()
   {
       if($this->session->userdata('logged_in')==TRUE)
       {
           $this->load->view('main_page');
       }
       else
           $this->load->view('login_page');
   }  
    
    function login()
    {
    $username = $this->input->post('Username');    
    $password  = $this->input->post('Pass');
    
    $this->db->where('Username',   $username);
    $this->db->where('Pass', $password);
    $query =$this->db->get('system_userdetails');
    
    if ($query->num_rows() > 0)
        {
           foreach ($query->result() as $row)
           {
              echo $row->ID;
              echo $row->EmailAddr;
              echo $this->session->userdata('session_id');
              $newdata = array(
                   'username'  => $row->Username,
                   'email'     => $row->EmailAddr,
                   'logged_in' => TRUE
               );
              
              $this->session->set_userdata($newdata);
           }
           redirect('User/index');
        }
    else
        {
           $this->load->view('login_page');
          
        }
      
      
    }  
  }

This works fine to login, but now i want to check if theres been no page load for say 10 mins, the session should get destroyed, and the user would have to re-login, but as long as the user stays active, the session continues..

How can i achieve that? I tried the Benchmark Class, however it seems to not work when the functions/controllers switch. (i.e I cant mark the starting point in my login function, and mark an ending point in another controller.. and check the time.)
When i echo'ed the value of time elapsed, if just gave me a blank page.

Please Help.

Thanks in advance
#23

[eluser]charlie spider[/eluser]
hey Michael...

"and my CI Dev Pack" = Not Found The page you are looking for is not here.

i really wanted to see it too.




Theme © iAndrew 2016 - Forum software by © MyBB