0

I am writing a login file and I want to go back to the previous page and not the homepage after I successfully login.

public function LoginUser(){
  if($checkEmail  == 1){
     header('refresh: 0 ; /')
  }
}
ChrisM
  • 505
  • 6
  • 18

2 Answers2

0

I recommended you store the previous page in a $_SESSION or temporary variable where you save your previous page because not all navigators can handle history.go(-1) and like this you can guarantee the user will redirect to the right page.

ChrisM
  • 505
  • 6
  • 18
0

Try this code. After successful login redirect to the desired page.

public function LoginUser(){
  if($checkEmail  == 1){
     redirect('/provide your controller name/');    
  }
}
deavapriya
  • 67
  • 10