Welcome Guest, Not a member yet? Register   Sign In
Having an issue with flash data not remembering my session data
#1

[eluser]Unknown[/eluser]
Hi all,

I'm having an issue with my login controller method. What I'd like it to do is redirect the user back to the domain it was referred from after successfully logging in. The problem seems to be that the flash data is not getting saved after the successful login. I've confirmed that it is correctly being set in the database session prior to the login, but after the post request, it seems to not remember the session any longer, even though I'm trying to access it prior to setting the new session after login. Here's the method, any suggestions would be appreciated.

Code:
function login()
{

if(isset($_SERVER['HTTP_REFERER']) && preg_match('/test.com/', $_SERVER['HTTP_REFERER'])){
  $this->db_session->set_flashdata('requested_page','http://test.com');
}

$this->db_session->keep_flashdata('requested_page'); // this doesn't seem to help, but left it in just in case

$requested_page = $this->db_session->flashdata('requested_page');
    
if(count($_POST) > 0 && $this->auth->login()){
  
  if($requested_page != ""){
   $this->db_session->set_flashdata('requested_page', '');
            redirect($requested_page, 'location');
  }
  else{
   redirect('main', 'location');
  }
}
else {
     $this->load->view('container',$data);
}
}




Theme © iAndrew 2016 - Forum software by © MyBB