Last active
September 4, 2017 15:12
-
-
Save mahadirz/a47f30167626a43a0b3daddd6b81ea9a to your computer and use it in GitHub Desktop.
Capture session_id into cookie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$offerId = intval($_GET['offer_id']); | |
$orderId = $_GET['adv_sub']; | |
$amount = floatval($_GET['amount']); | |
$transactionId = $_GET['transaction_id']; | |
//do whatever you want to do with the variables | |
//ie cross check database for clicks and save into database | |
//printf("Offer ID %d<br>",$offerId); | |
//printf("Order ID %s<br>",$orderId); | |
//printf("Amount %.2f<br>",$amount); | |
//printf("Transaction ID %.2f<br>",$transactionId); | |
//show 1x1 pixel gif image | |
header('Content-type: image/gif'); | |
$content = base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw=='); | |
echo $content; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var ssSessionId = ssGetURLParameter('session_id'); | |
var ssDocName = 'SSSID'; | |
var ssDataExpired = ssCalculateExpireDate(30); | |
if (ssSessionId !== null) { | |
ssSetCookie(ssDocName, ssXSessionId, ssDataExpired); | |
} | |
function ssGetURLParameter(name) { | |
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null | |
} | |
function ssSetCookie(cName, cValue, exDate) { | |
var expires = "expires="+exDate; | |
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/"; | |
} | |
function ssCalculateExpireDate (days) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (days*24*60*60*1000)) | |
d.toUTCString() | |
return d; | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script language="javascript" type="text/javascript"> | |
<!-- Start of ShopStylers GTM Tag --> | |
<!-- Please do not modify --> | |
var ssOrderID = document.getElementById("SX-GTM-orderid").innerHTML; | |
var ssAmount = document.getElementById("SX-GTM-total-amount").innerHTML; | |
function getCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for(var i=0; i<ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0)==' ') c = c.substring(1); | |
if (c.indexOf(name) == 0) return c.substring(name.length, c.length); | |
} | |
return ""; | |
} | |
var ssSessionID = getCookie('SSSID'); | |
if(ssSessionID !== "") { | |
var ssUrl = "https://xxx.xxx.com/aff_l?offer_id=xxx" +"&adv_sub=" + ssOrderID + "&amount=" + ssAmount +"&transaction_id=" + ssSessionID; | |
var iframe; | |
iframe = document.createElement('iframe'); | |
iframe.src = ssUrl; | |
iframe.width='1px'; | |
iframe.height='1px'; | |
iframe.scrolling='no'; | |
iframe.style.display = 'none'; | |
document.body.appendChild(iframe); | |
} | |
<!-- End of ShopStylers GTM Tag --> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment