0

Is there a way to get cookies for specific domain (Facebook) and delete all them using JavaScript?

I want to delete cookies for oAuth (Facebook and Gmail) when the user logs out.

4
  • 2
    Is this for a browser extension, or to be run in a webpage? You can't do this if you're running it from a webpage; it's horribily insecure and wide open to abuse. Commented Nov 30, 2011 at 11:49
  • i have done login using oAuth, i need to delete cookies of facebook from my application Commented Nov 30, 2011 at 11:53
  • 1
    Yes, you said that in your original question. Regurgitating what you've already posted doesn't further my understanding of your problem. Commented Nov 30, 2011 at 11:55
  • If you could use cookies from facebook.com, you could probably steal your visitor's Facebook account. I think you haven't explained your need but the solution you've figured out. I suggest you explain what you want to accomplish; it's possible that it can be done. Commented Nov 30, 2011 at 12:03

3 Answers 3

2

No, that is not possible.

You can only access the cookies of your own domain. You can't even see the cookies from a different domain.

Sign up to request clarification or add additional context in comments.

Comments

0

The jQuery Cookie plugin is useful for getting the value of a cookie when you already know the name of the cookie you want to query, but provides no way to get a list of all the cookies that are set.

Refer this DOC for details !!!!

For deleting cookies you can use eraseCookie function

2 Comments

I could be wrong, but as far as I know, JavaScript is only able to access cookies for the domain it's been downloaded from.
@JamWaffles :if you wanna delete use eraseCookie
0

So if I understand this correctly you actually want to logout the user from FB... Have you tried using the FB SDK logout() function? That will successfully delete all FB cookies from your domain.

Hope this helps

2 Comments

FB.logout(function (response) { alert('user is now logged out');}
yes, that's a known issue with FB - check this for PHP or some client code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.