Maintain a Facebook user ID in a session

I am trying to add facebook login to my website. I authenticated using the JavaScript JavaScript SDK on facebook and created a cookie with a user ID. The problem is that when a user logs out (I delete all cookies) and moves to another page on the site, I still see a cookie with data.

The following are the functions that I use to create and destroy cookies:

Utils.createSessionCookie = function(id, name, access_token) { if (Utils.getCookie(Consts.USER_ID) == null) { Utils.setCookie(Consts.USER_ID, id, 1); Utils.setCookie(Consts.NAME, name, 1); Utils.setCookie(Consts.ACCESS_TOKEN, access_token, 1); } }; Utils.destroySessionCookie = function() { Utils.setCookie(Consts.USER_ID, '', -1); Utils.setCookie(Consts.NAME, '', -1); Utils.setCookie(Consts.ACCESS_TOKEN, '', -1); }; Utils.setCookie = function(name, value, days) { var expireDate = new Date(); expireDate.setDate(expireDate.getDate() + days); var cookieValue = escape(value) + ((days == null) ? "" : ";expires=" + expireDate.toUTCString() + "; path=/"); document.cookie = name + "=" + cookieValue; }; 
+7
source share
1 answer

Note. Just help answer the OP question.

According to the comments above, there is an error in user codes that repeatedly creates a cookie. These are not Facebook SDK errors.

After resolving the cookie problem, Facebook works fine.

+1
source

All Articles