Twitter callback for multiple follow buttons: bind unique function on follow event for each individual Follow button?


I want to use Twitter’s web intents to create multiple follow buttons on the same page and create a unique cookie (let’s say cookie1 for button 1, and cookie2 for button 2) every time the visitor clicks one of the Follow buttons.

What happens with the current code is that all the cookies get created instantly after clicking one of the Follow buttons, rather than a single cookie for the user that gets followed (ie ‘cookie1’ when user1 gets followed, ´cookie2’ when user2 gets followed etc.)

This is my current code. Imagine it 3 times for user1, user2, and user3. I’m including Twitter widget-js for web-intents in the header.

    <a href= class='twitter-follow-button'   data-show-count='false' data-size='large'>Follow @user1</a>
	    twttr.ready(function (twttr) {'follow',   function(e) {
				document.cookie =  'cookie1=1; expires=Fri, 3 Aug 2999 13:33:37 UTC; path=/';


You should not have 3 event handlers, but one. The event handler can know what button was pressed with for example and (e being the first parameter to the event handler).
More details there: