I'm in the middle of transitioning some perl scripts from a linux/apache combo to a win2k/iis combo. Most of the scripts I've been able to move over without a single line of code being changed. However, I have a script that uses cookies, and herein lies the problem.
Basically, the script is a multi-state script. On "login", after retrieving some info a session based cookie is set (
set_cookie). On any other state, the cookie is retrieved (
get_cookie). This works as expected on apache.
After moving this script to the win2k box, cookies stopped working as expected. I can't seem to retrieve the cookie that I'm pretty sure is being set. Here's the code:
sub set_cookie {
###########################################
# Create a cookie. We have a few different
# "states" and all of them require at least
# *some* user information
# Uses a global CGI object ($p) to create
# the cookie
###########################################
# Get the passed user information
my %ui = @_;
# set the params for the cookie
my $cookie = $p->cookie(
-name => 'mycookie',
-value => qq(Name:$ui{'Name'}:Phone:$ui{'Phone'}:EmployeeNum:$ui{'Em
+ployeeNum'}:Email:$ui{'Email'}:SapId:$ui{'SapId'}:NTID:$ui{'NTID'}:Pr
+ovince:$ui{'Province'}),
-expire => '',
);
# send it to the browser
print $p->header(-cookie => $cookie);
}
and to retrieve the information:
sub get_cookie
{
################################################
#Retrieve the cookie
#Uses a global variable ($p) for the CGI object
#Returns user information
################################################
my %userinf;
if ($p->cookie('mycookie'))
{
my $values = $p->cookie('mycookie');
%userinf = split /:/,$values;
}
else {
display_login(); #No cookie, force a login
}
print $p->header();
return (%userinf);
}
As mentioned above, this works great using apache, fails miserably using IIS (though everything else in the script runs fine).
Any ideas?