I’m now already trying to solve the following problem for a while. I tried different solutions, but can’t seem to find a working one
I’m trying to do……
On my website I have some forms for the visitor to fill-in. On these form I asked the visitor, how he or she found us. But I found out that not a lot of people answer the question accurate. So I would like to set a cookie with the referer on the page a visitor enters my website (usually http://www.domain.com/index.html) and read the cookie when the form (a couple of pages further.....) is filled in. The reading parts works fine. It’s getting the referer and putting it into a cookie.
What did I try………..
A lot. First I made a script that set’s a cookie based on the HTTP_REFERER and displays an image (1x1 pixel). It works if you surf directly to the script, but included as an image-tag in index.html the referer doesn’t seem to pass. Probably, but I’m not 100% sure this is because the referer isn’t forwarded to the image tag. (?!) I alsow tried to make a script working as an javascript sourse file, but did’t work for the same reason.
So I thought: get the referer with javascript and print an image-tage with the document.write statement. For this I made sure that the script sets the cookie based on the param r [$referer = $in->param('r');]. The good thing is that if surf directly to the script (and manually give a r=) it works, only again it doesn't seem to work in combination with the javascript I have.
My question………….
Before I upload all the codes and snippets I tried I would like to ask you guys, what would be the best way of solving this problem. Which technologies or way of working. Then I can try to make i happen myself!
Note: (Just to avoid comments about the cookie setting )
I don set the complete referer as the cookie value, but cleansed and crypted. For this I use the following two lines of code. Thanks to Paul for the code. Many thanks acually!
my $referer = ‘http://www.foo.bar/pagename’; my $crypt;
$referer =~ s|^http://([^/]+).*|$1|i;
$crypt = join ("-", map { ord } (split //, $value));
I’m trying to do……
On my website I have some forms for the visitor to fill-in. On these form I asked the visitor, how he or she found us. But I found out that not a lot of people answer the question accurate. So I would like to set a cookie with the referer on the page a visitor enters my website (usually http://www.domain.com/index.html) and read the cookie when the form (a couple of pages further.....) is filled in. The reading parts works fine. It’s getting the referer and putting it into a cookie.
What did I try………..
A lot. First I made a script that set’s a cookie based on the HTTP_REFERER and displays an image (1x1 pixel). It works if you surf directly to the script, but included as an image-tag in index.html the referer doesn’t seem to pass. Probably, but I’m not 100% sure this is because the referer isn’t forwarded to the image tag. (?!) I alsow tried to make a script working as an javascript sourse file, but did’t work for the same reason.
So I thought: get the referer with javascript and print an image-tage with the document.write statement. For this I made sure that the script sets the cookie based on the param r [$referer = $in->param('r');]. The good thing is that if surf directly to the script (and manually give a r=) it works, only again it doesn't seem to work in combination with the javascript I have.
My question………….
Before I upload all the codes and snippets I tried I would like to ask you guys, what would be the best way of solving this problem. Which technologies or way of working. Then I can try to make i happen myself!
Note: (Just to avoid comments about the cookie setting )
I don set the complete referer as the cookie value, but cleansed and crypted. For this I use the following two lines of code. Thanks to Paul for the code. Many thanks acually!
my $referer = ‘http://www.foo.bar/pagename’; my $crypt;
$referer =~ s|^http://([^/]+).*|$1|i;
$crypt = join ("-", map { ord } (split //, $value));