lundi 20 juin 2016

Session not really flush,why?

I met a problem.here are my codes(the codes are in Controller):

  public function login(Request $request){

    $name = $request->name;
    $pwmd5 = md5($request->pw);
    $result= user::select(DB::raw("CASE WHEN password ='$pwmd5' THEN 1 ELSE 0 END AS passwrod_matches,id,name"))
    ->where('name',$name)
    ->first();

    if ($result == null) {
        return returnFormat('account wrong', false);
    } elseif ($result['password_matches'] == '0') {
        return returnFormat('pw wrong', false);
    };
    $result['password_status'] = '1';
    static::saveUser($result);
    return returnFormat($result);
   }

  static public function saveUser(&$user){

    if(!is_array($user)){
        $user->toArray();
    }
    $user['sid'] = Session::getId();
    session(['user'=>$user]);

   }

public function checkUser(Request $request){

    $user = session('user');
    return $user;

}

public function logout(Request $request){


    session()->flush();
    return returnFormat(true);

}


what I did is login()-> checkuser()-> logout(); But when I login() with another account,I found that the session Id is exactly the same..why?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire