Welcome Guest, Not a member yet? Register   Sign In
Session / Login help
#11

[eluser]gbd_dee[/eluser]
here is my logout controller

Code:
<?php

class Logout extends CI_Controller {

    
    
    function Logout()
    {
        parent::__construct();
    }
  
    
    public function index()
    {
        $this->logout();
        
    }//index
        
    public function logout()
    {
        $this->unset_userdata('user_email');
        $this->session->sess_destroy();
        redirect(base_url().'User/login');
    }//logout
        
        
}
#12

[eluser]gbd_dee[/eluser]
this is how im setting my custom session variables in my main controller

Code:
$this->session->set_userdata('username',$full_name);
                   $this->session->set_userdata('user_email',$email);
                   $this->session->set_userdata('login_attempt','6');
                   //print_r($this->session->all_userdata());
                   $this->selectView($data);
#13

[eluser]gbd_dee[/eluser]
sorry I have to put code in separate post or it flags it as spam bc im new to forum....


Now I want to create a controller called profile which basically gathers the users info from a model (which i have the model already and I know how to retrieve data) Profile controller and view needs to be restriced... how do I do this
#14

[eluser]InsiteFX[/eluser]
I suggest that you take a look at one of the Auth systems in the IgnitedCode forum topic.
#15

[eluser]Stefan Hueg[/eluser]
[quote author="InsiteFX" date="1335839899"]
@stefan Hueg,
And how do you figure I have missed directed him?

If you do not unset the session userdata it will still exist, because there is no telling when the garbage collector will clear out the session!

Look at your session table and tell me how many sessions you have left in it...
[/quote]

Look closely at the sess_destroy() function at the session class. It will delete the entry from your session table and reset the cookie. No need to manually unset the userdata.

But not only that, his misconception was that he tried to do a redirect in a view if the user is not logged in.




Theme © iAndrew 2016 - Forum software by © MyBB