Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. var hasAffiliateParam = window.location.href.indexOf("ref") > -1;
  2. var affiliateId = null;
  3. if (hasAffiliateParam) {
  4. var queryString = window.location.href.split("?")[1];
  5. queryString = queryString.split("#")[0];
  6. var arr = queryString.split("&");
  7. for (var i = 0; i < arr.length; i++) {
  8. var keyAndValue = arr[i].split("=")
  9. if (keyAndValue[0] === "ref") {
  10. affiliateId = keyAndValue[1];
  11. break;
  12. }
  13. }
  14. }
  15.  
  16. function setCookie(cname, cvalue, exdays) {
  17. var d = new Date();
  18. d.setTime(d.getTime() + (exdays*24*60*60*1000));
  19. var expires = "expires="+ d.toUTCString();
  20. document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
  21. }
  22.  
  23. if (affiliateId) {
  24. setCookie("affwp_ref", affiliateId, 365)
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement