Skip to content

Instantly share code, notes, and snippets.

@underdown
Created June 10, 2012 22:58
Show Gist options
  • Select an option

  • Save underdown/2907596 to your computer and use it in GitHub Desktop.

Select an option

Save underdown/2907596 to your computer and use it in GitHub Desktop.
Set Cookie On Like/unlike (FBML)
<script>
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
};
FB.Event.subscribe('edge.create', function(response) {
SetCookie("liked",1,365)
});
FB.Event.subscribe('edge.remove', function(response) {
SetCookie("liked",0,365)
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment