Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
Forum Search
Google Site Search
 All Forums
 General
 Suggestions - NOT QUESTIONS
 Set ECT cookies in Javascript
Author « Topic »  

Graham Slaughter
Ecommerce Template Expert

836 Posts

Posted - 02/25/2025 :  08:40:40  
Howdy Vince,

I've been trying to hunt down why I wasn't getting affiliate cookies referenced on customer orders. I was going to use that to help us keep track of PPC performance.

Turns out, because the cookie is set in the .asp code, it wont work if the page is cached (in cloudflare for us).

The workaround for this of course would be to read and write the cookie using Javascript instead.

I added a little conditional addition of javascript to the footer that seemed to fix it up just fine.

<%
'capture the PARTNER querystring as a cookie if it is in the URL
if request.querystring("partner") <> "" then
%>
<script>
document.cookie = "partner=<%=request.querystring("partner")%>; max-age=31536000; path=/";
</script>
<%
end if
%>


It's worth noting that any part of the code that uses this will not work if the page isn't served from origin:

sub setacookie(cname,cval,cdays)
response.cookies(cname)=cval
if cdays<>0 then response.cookies(cname).expires=date()+cdays
if request.servervariables("HTTPS")="on" then response.cookies(cname).secure=TRUE
end sub


I imagine you could make something better than what I crafted there.

- Graham
  « Topic »  
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.02 seconds. Snitz Forums 2000