Below is the CGI program to deliver JavaScript popup code, or empty code, depending on whether or not a certain cookie has been set.
Installation instructions:
All edits must be done with a plain text word processor such as NotePad or BBEdit. In the article, the example named the script monitor.cgi, but you may name it as you wish.
Ensure that the first line of the script points to the perl on your server. (This script requires Perl version 5+)
If the cookie name in the
my $CookieName = 'multidomaincookie';line conflicts with other cookies your "cookie handler domain" uses, change this one.Replace the digit in the
my $DaysCookieLives = 1;line with the number of days you want to cookie to live in your visitor's browser. Maximum 3652(10 years) and minimum 0 (automatically deletes when browser closes).Replace
# Replace with code to publish if cookie is NOT present.with the JavaScript popup code function. Example:function Popup() { window.open('popup.html','','width=400,height=200'); }
Note: Type only the JavaScript code, not the leading <script...><!--or the following//--></script>Replace
# Replace with code to publish if cookie IS present.with an empty JavaScript function of the same name that you specified in the previous step. Example:function Popup() { }Upload the script into a directory on your cookie handler domain that can run Perl CGI scripts. Upload it with FTP as ASCII/plain text, not binary.
Ensure the script has global execution permission, 0755 on Unix/Linux.
The related article was first published in WillMaster Possibilities, titled, "Multi-Domain Cookies." Please see the article for additional informaiton. It is linked from the WillMaster Possibilities archives.
Here is the CGI program: