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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.