0

I can't store data to session storage when I redirect to user, how can I fix this ? if add a view instead redirect, it works.. but below codes doesn't work..

public function makeLogin(){
        $model = new User();
        $user = $model->read()->where("username","=",post("username"))->first();
        if(password_verify(post("password"),$user['password'])){
            $_SESSION['auth']['user'] = $user['name'];
            $_SESSION['auth']['username'] = $user['username'];
            $_SESSION['auth']['user_role'] = $user['user_role'];
            return redirect('redirect-core');
        } else {
            session("message","wrong username or password");
            session("message_type","danger");
            return redirect(ref_url());
        }
    }

session() helper

function session($name = null,$message=null){
   if (is_null($name) && is_null($message)){
       return new \Core\Session();
   } else {
       $_SESSION[$name] = $message;
   }
}

redirect() helper

function redirect($url){
     if (substr($url,0,4)==="http"){
         header("Location:".$url,true,303);
     } else {
         header("Location:".APP_URL."/".$url);
     }
}
tereško
  • 58,060
  • 25
  • 98
  • 150
Elliot
  • 11
  • 6

0 Answers0