Welcome Guest, Not a member yet? Register   Sign In
Do I need to check the user logged or not in these two method?
#1

[eluser]ted wong[/eluser]
First, I have a create function in the msg class.
It will generate the UI, when the msg the form, I will have a function call
valid_create....
after valid, I will have commit_create function to handle it.
But seems the user will connect the website via...
..../msg/create <--this link for the form.
..../msg/valid_create <---this link for checking.
Seems, create msg required login, so, in the create function, I have a need function like check_login(), if this is false, I will back to the login page. But both the create and valid_create should have the validate login function, do I both need check_login() in this function?

Thank you.
#2

[eluser]pickupman[/eluser]
I think I may understand correctly. I common approach is what you are mentioning.
Code:
function create(){

if($this->session->userdata('logged_in') != TRUE){
    $this->session->set_userdata('last_uri', 'msg/create');
    redirect('user/login');
}

  //rest of create form

}

//Login form
function login(){
  
   //Check users login code here
  
   //Redirect user
   $redirect = $this->session->userdata('last_uri');
   if( !empty($redirect) ){
      redirect($redirect);  //Redirect user to last visited page
   }else{
      redirect('/');  //Otherwise redirect to home page
   }
}




Theme © iAndrew 2016 - Forum software by © MyBB