Weird Cookies in Safari
I have no where else to turn for help. My ISP support recommended I post this on some discussion boards so I thought I'd see y'all think. I've been working on this for several hours, and I can't seem to find any error that I've made. Any help you can provide will be very welcomed.
On one of my websites, we have a perl library that is not working in Macintosh Safari..
There are subroutines in this file that are called from several other files. I should note that everything works fine in other browsers, just not Safari.
The subroutine in this file simply reads two cookies that have been stored when users login and places that info in a variable. The problem is that this isn't working -- the script returns an empty string. It does not return the cookies set. I can see that the cookies are set -- it's just a matter of reading them back into a variable.
Here's the code from the library file:
my $thequery = new CGI;
my $thecookie1 = $thequery->cookie("name");
my $thecookie2 = $thequery->cookie("other");
Simple enough -- the problem is that $thcookie1 and $thecookie2 are blank once this part of the code is executed. I know this because to test, I added an "if-then" statement to check (not to mention simply calling a print of the variables). Yet, I can see that the cookies have been set, and they are visible in the cookies window (safari->preferences->security).
In my Perl scripts that call this subroutine, I do include "use CGI;" -- BTW, it's not returning any error string when executed. Simply, these variables are empty!
What's weird is that I also administer another website in a completely different account, but same ISP. Many of my Perl scripts are identical. I also have the same lib on this website as well and it works great without any problems. This is the weird part -- same file, housed at same ISP, works in one account but not the other.
Because I thought there might be something wrong with my file, I tried many things including simply copying the file from website2 to website1 via FTP (ie, two simulteneous FTP connections). This also yielded no results.
I've also tested this on multiple machines and with multiple connections -- ie., it's not a single-client issue from what I can tell. My only guess is ... well, at this point, I have no guess....
thanks in advance for help.
Something to try...
If you are not alreading doing it, include a path in your cookie when you write it.
my $cookie1 = "name=$name;path=/";
my $cookie2 = "other=$other;path=/";
Yeah -- it's working now. Thanks for all of your help-
In case you're interested, the issue was this:
The cookie was being set to "http://domain.org" -- ie., without the "www." in the address
and the scripts were calling "http://www.domain.org/cgi-bin/etc...."
Because of this, Safari was thinking the cookie was from another site -- hows abouts that mac security!
One freakin' line of code solved the problem. When I set the cookie now, i simply added an option of the CGI pm:
voila! it's workin' now. Thanks again for your help-you gave me the idea to set the cookies with the path!!!
Last edited by bigcomposer; 08-29-2006 at 05:22 PM.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)