Welcome Guest, Not a member yet? Register   Sign In
Session/Encryption
#1

[eluser]terry101[/eluser]
i have been creating a login recently and i'm at the part where i have to create a session where its encrypted and a cookie is set. To be safe i wanted to store the session id in my database and do a match each time the session comes up to validate if a new session should be created or not. I am confused on how to do most of these functions. i have tried but i'm not sure if i have dont it correctly.

i got up to creating a session where it gets encrypted but i'm stuck on if the session was successful or not. I'm also lost on how to produce a session id. Assistance needed.


Code:
if ($this->form_validation->run() == FALSE) {
            
            $this->load->view('loginview');
        }
        else {
        
                $this->load->model('loginmodel');
                 $username = $this->input->post('username');
         $password = $this->input->post('password');
            
                if ($this->loginmodel->check_login($username, $password)){
    
                    //echo 'your in';
                        $this->start_session();
                    }
            
            else {
                
                echo 'Username or password is invalid, try again';
            
            }            
        }
    }
    
    function start_session() {
        
            // loading sessions
                $this->load->library('session');
                $this->load->library('encrypt');
                //$store_sess_data  = array ('logged_in' => TRUE, 'user_id' => $username, 'last_active' => 'timestamp')
            $whats_on_sess = $this-> session->set_userdata(array (
                'logged_in' => TRUE,
                                'session_ID =>
                'user_id' => $username,
                'last_active' => 'timestamp')
                );
                $encrypt_sess = $this->encrypt->encode($whats_on_sess);
              $this->load->view('sessionview');
    }




Theme © iAndrew 2016 - Forum software by © MyBB