After perusing this site and many others over the last couple days I decided its time to ask my own question. I am using the Instagram API and want to do a simple user logout. I am storing a session variable on my side to track when a user is logged in, and destroying when they logout. After destroying the session (and eventually the Instagram auth token), I have it set to redirect to my homepage where a new user can login. I have this working fine except for one hiccup.
When I erase my session variable and redirect to the homepage, I can't re-login as another user. Going to the IG login page just automatically logs in whoever the last user logged in was.
To combat this, I have tried:
Clearing my cookies does absolutely nothing.
Opening the logout URL in a new tab automatically logs me back in.
Opening a hidden iFrame gives me an error and opening a hidden img does nothing.
Doing an AJAX call is not working due to cross-domain issues.
My Code:
$(document).on("click", "#logout", function() {
console.log("logout");
$.ajax({
type: "POST",
dataType: "text",
data: {token : "-1"},
url: "http://localhost/Paytag/wp-content/themes/blankslate/set_cookie.php",
success: function(data){
console.log(data);
}
});
$("#account-div").append("<img src='http://instagram.com/accounts/logout/' width='0' height='0' />");
location.href='http://localhost/Paytag';
})
Thanks for any help you can offer!
So the solution is painfully obvious. I had the logout URL wrong all the time.
It VERY SPECIFICALLY has to be this URL:
https://www.instagram.com/logout/
I either didn't include the https://, www or trailing slash, or any combination of the three. I hope this helped somebody!
Instagram的注销链接是https://www.instagram.com/accounts/logout/ ,它适用于我
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.