I think if we make calls to Facebook using REST or Graph API, we will know if it is fake because it will come back saying fake session / auth_token / access_token. But what if we are showing our own DB info, such as the user’s “most preferred product list”, then we don’t make any call to Facebook but show our DB’s data. How do we know it is really the user, not somebody faking the cookie?
Share
When you read a cookie with facebook it contains a value called ‘sig’. With this value, the other cookie values, and your app secret you hash the contents of the cookie and validate it against the sig. If they match, then the cookie is valid. You can trust this result because only you and Facebook have access to the app secret. Here is the example of how Facebook’s PHP SDK does it. Any respectable Facebook SDK will do this all for you internally.
Here is the same thing in C# (Facebook C# SDK):