Best Way to Display Cookie Value?
When a visitor hits my site for the first time a cookie is set based on the referral source (Google, Yahoo, etc.) and based on the source a unique toll free phone number is set to a cookie. What is the best way to display that cookie phone number value? It will be displayed in mulitple places on the web site include content paragraphs, custom controls, etc.
Hi Matt,
How do you want to display the cookie - via client code or via server code? Here is a method for reading a cookie with a specific name:
function
readCookie(name)
var
nameEQ = name +
"="
;
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,c.length);
if
(c.indexOf(nameEQ) == 0)
return
c.substring(nameEQ.length,c.length);
return
null
;
Thanks for the response. This will save me a bunch of time.