adiv-phpian / instagram-private-api-laravel

Instagram private API in laravel application
8 stars 1 forks source link

Logout functionality implementation. #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

@muthu-kc Nice to meet you, and thanks for your sharing work.

I just wanted to know about the logout functionality in detail. I can see you've implemented the logout functionality via following codes. (in the IPController.php file)

public function logout(){
  Session::forget("pk");
  Session::forget("proxy");
  return redirect("/");
}

I am wondering if this function make the user logout from the instagram exactly like when user click on the Logout button on the official instagram web page.

Please let me know if I have any misunderstanding. Thanks.

adiv-phpian commented 6 years ago

@Flow999Cloud That one is general laravel session logout. I added function for instagram logout. I used liam cottle library function for logout. You can use any functions from liam cottle library with instagram class.

public function instagram_logout(){

      $user = IPModel::where(['instagram_user_id' => \Session::get('pk')])->with('ip')->get()->first();

      $instagram = new \Instagram\Instagram();
      $instagram->setProxy($user->ip);
      $instagram->initFromSavedSession($user->user_session);

      $response = $instagram->logout();

      Session::forget("pk");
      Session::forget("proxy");
      return redirect("/");
    }

But looks like even though I get ok status from instagram logout, I can able to use the old session. I don't understand whether instagram keep old session until next login or logout function from liam cottle library not working properly.

ghost commented 6 years ago

@muthu-kc
Thanks for your detailed explanation and quick reply. I really appreciate it.